Skip to content

Instantly share code, notes, and snippets.

@phpfunk
Last active October 12, 2015 19:28
Show Gist options
  • Select an option

  • Save phpfunk/4076244 to your computer and use it in GitHub Desktop.

Select an option

Save phpfunk/4076244 to your computer and use it in GitHub Desktop.
Share VPN / OS X
# 1. Connect VPN on your laptop
# 2. Save this to a file named share.sh (i have it saved to a folder named /shell/vpn/)
#!/bin/sh
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
# 3. Save this to a file named unshare.sh in the same folder
#!/bin/sh
killall natd
ipfw -f flush
sysctl -w net.inet.ip.forwarding=0
# 4. Change the permissions on both files to 775
# 5. Open terminal and run: $ sudo ./share.sh
# 6. Now your laptop is ready to share your VPN connection
# 7. Open your device and update the gateway to the local IP address of your computer, in my case 10.0.1.5, you will have to change your settings to set up a static IP address.
# 8. After that is done, you should be able to leech off your VPN connection on your laptop to any device that is going thru the gateway of your computer
# To turn off sharing open terminal, cd to correct directory and run $ sudo ./unshare.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment