Skip to content

Instantly share code, notes, and snippets.

@tapionx
Created February 25, 2014 15:03
Show Gist options
  • Save tapionx/9210555 to your computer and use it in GitHub Desktop.
Save tapionx/9210555 to your computer and use it in GitHub Desktop.
router
#!/bin/bash
if [ "`id -u`" -eq 0 ]; then
if [ "$2" ]; then
INIF=$1
OUTIF=$2
iptables --table nat -I POSTROUTING 1 --out-interface $OUTIF -j MASQUERADE
iptables -I FORWARD 1 --in-interface $INIF -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
else
echo "Usage: $0 <input iface> <output iface (internet)>"
exit 0
fi
else
echo "You must be root"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment