Skip to content

Instantly share code, notes, and snippets.

@chihchun chihchun/
Created Apr 16, 2010

What would you like to do?
# Copyright (c) 2010 Rex Tsai <>
# Description
# * Setup wlan0 as ad-hoc interface
# * make eth0 as gateway, change it if you like to use other inteface like ppp0
# /etc/init.d/shorewall restart
# we don't want network manager to manage networks
# /etc/init.d/network-manager stop
sysctl -w net.ipv4.conf.all.forwarding=1
sysctl -w net.ipv4.conf.default.forwarding=1
iptables -I INPUT 1 -i ${WLAN} -d -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i ${WLAN} -o ${ROUTE} -s -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
# transparent proxy
# iptables -t nat -A PREROUTING -i ${WLAN} -p tcp --dport 80 -j REDIRECT --to-port 3128
# iptables -I INPUT 1 -i ${WLAN} -d -p 3128 --dport tcp -j ACCEPT
# DNAT settings
# iptables -t nat -A PREROUTING -i ${WLAN} -p tcp --dport 1194 -j DNAT --to-destination
# iptables -t nat -A PREROUTING -i ${WLAN} -p udp -m multiport --dports 53,1194 -j DNAT --to-destination
# iptables -A FORWARD -i ${WLAN} -d -p tcp --dport 1194 -j ACCEPT
# iptables -A FORWARD -i ${WLAN} -d -p udp -m multiport --dports 53,1194 -j ACCEPT
ifconfig ${WLAN} down
iwconfig ${WLAN} mode ad-hoc
iwconfig ${WLAN} essid rex
ifconfig ${WLAN}
ifconfig ${WLAN} up
dnsmasq --listen-address= \
--interface=${WLAN} \
--dhcp-range=,,1h \
--no-daemon \
--log-dhcp \
--log-queries \
--enable-dbus --all-servers \
-i ${WLAN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.