Created
February 25, 2014 15:03
-
-
Save tapionx/9210555 to your computer and use it in GitHub Desktop.
router
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/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