Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simple IP masquerading script

  • Loading branch information...
commit 87d377e2ade1cb94ad4b5c109516c9e68ee32d78 1 parent 58a04e6
Akkana Peck authored
Showing with 29 additions and 0 deletions.
  1. +3 −0  README
  2. +26 −0 masq
3  README
View
@@ -49,3 +49,6 @@ epubtag.py:
analemma.py:
Plot the analemma from the selected location, using PyEphem and PyGTK.
+masq:
+ Set up IP masquerading to talk to another computer, such as a
+ Raspberry Pi, over eth0 while using wlan0 for the internet.
26 masq
View
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Set up IP masquerading to the Raspberry Pi.
+# Partially adapted from
+# http://www.ibiblio.org/pub/linux/docs/howto/other-formats/html_single/Masquerading-Simple-HOWTO.html
+
+pi_net=192.168.0
+
+# Don't actually need to know the Pi's intended address, just the network.
+#pi_addr=97
+
+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
Please sign in to comment.
Something went wrong with that request. Please try again.