Browse files

Simple IP masquerading script

  • Loading branch information...
1 parent 58a04e6 commit 87d377e2ade1cb94ad4b5c109516c9e68ee32d78 @akkana committed Nov 2, 2012
Showing with 29 additions and 0 deletions.
  1. +3 −0 README
  2. +26 −0 masq
@@ -49,3 +49,6 @@
Plot the analemma from the selected location, using PyEphem and PyGTK.
+ Set up IP masquerading to talk to another computer, such as a
+ Raspberry Pi, over eth0 while using wlan0 for the internet.
26 masq
@@ -0,0 +1,26 @@
+# Set up IP masquerading to the Raspberry Pi.
+# Partially adapted from
+# Don't actually need to know the Pi's intended address, just the network.
+myaddr=$(ifconfig wlan0 | grep 'inet addr:' | sed -e 's/.*addr://' -e 's/ *Bcast:.*//')
+echo My wlan0 address is $myaddr
+modprobe ipt_MASQUERADE
+iptables -F
+iptables -t nat -F
+iptables -t mangle -F
+iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $myaddr
+echo 1 > /proc/sys/net/ipv4/ip_forward
+iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
+iptables -A INPUT -m state --state NEW ! -i wlan0 -j ACCEPT
+iptables -P INPUT DROP
+ifconfig eth0 ${pi_net}.1 up

0 comments on commit 87d377e

Please sign in to comment.