Skip to content

Instantly share code, notes, and snippets.

@finnigja
Created April 25, 2012 17:06
Show Gist options
  • Save finnigja/2491336 to your computer and use it in GitHub Desktop.
Save finnigja/2491336 to your computer and use it in GitHub Desktop.
NAT'ing ethernet to wifi
#!/bin/bash
echo "1" > /proc/sys/net/ipv4/ip_forward
ifconfig eth0 192.168.200.1 netmask 255.255.255.0 up
/etc/init.d/isc-dhcp-server start
iptables --flush
iptables -t nat --flush
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.200.0/24 -j MASQUERADE
route add default gw 192.168.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment