Created
April 16, 2010 07:45
-
-
Save chihchun/368144 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright (c) 2010 Rex Tsai <[email protected]> | |
# | |
# Description | |
# * Setup wlan0 as ad-hoc interface | |
# * make eth0 as gateway, change it if you like to use other inteface like ppp0 | |
# | |
# INIC | |
# ONIC | |
WLAN=wlan0 | |
ROUTE=eth0 | |
# /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 10.8.8.1 -p udp --dport 53 -j ACCEPT | |
iptables -A FORWARD -i ${WLAN} -o ${ROUTE} -s 10.8.8.0/24 -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 10.8.8.1 -p 3128 --dport tcp -j ACCEPT | |
# DNAT settings | |
# iptables -t nat -A PREROUTING -i ${WLAN} -p tcp --dport 1194 -j DNAT --to-destination 192.168.2.2 | |
# iptables -t nat -A PREROUTING -i ${WLAN} -p udp -m multiport --dports 53,1194 -j DNAT --to-destination 192.168.2.2 | |
# iptables -A FORWARD -i ${WLAN} -d 192.168.2.2 -p tcp --dport 1194 -j ACCEPT | |
# iptables -A FORWARD -i ${WLAN} -d 192.168.2.2 -p udp -m multiport --dports 53,1194 -j ACCEPT | |
ifconfig ${WLAN} down | |
iwconfig ${WLAN} mode ad-hoc | |
iwconfig ${WLAN} essid rex | |
ifconfig ${WLAN} 10.8.8.1 | |
ifconfig ${WLAN} up | |
# DNS + DHCP | |
dnsmasq --listen-address=10.8.8.1 \ | |
--interface=${WLAN} \ | |
--dhcp-range=10.8.8.100,10.8.8.200,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