Created
June 18, 2011 18:01
-
-
Save alotaiba/1033342 to your computer and use it in GitHub Desktop.
This script is to turn on/off NATting through to a VPN server on Mac.
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 | |
# This script to turn on/off NATting through to a VPN server. | |
# Example would be turning the mac into a wireless router, and routing all the incoming | |
# traffic to the VPN server. | |
# Thanks to http://rodrigo.sharpcube.com/2010/06/20/using-and-sharing-a-vpn-connection-on-your-mac/ | |
case "$1" in | |
on) | |
echo "Turning NAT VPN on." | |
natd -interface tun0 | |
ipfw -f flush | |
ipfw add divert natd ip from any to any via tun0 | |
ipfw add pass all from any to any | |
sysctl -w net.inet.ip.forwarding=1 | |
;; | |
off) | |
echo "Turning NAT VPN off." | |
killall natd | |
ipfw -f flush | |
sysctl -w net.inet.ip.forwarding=0 | |
;; | |
*) | |
echo "To use the script, you can either turn the NAT VPN on or off:" | |
echo "./natvpn.sh on" | |
echo "./natvpn.sh off" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment