Mac OS X Internet Sharing

Got a problem with Viscosity or need help? Ask here!

James

User avatar
Posts: 2076
Joined: Thu Sep 04, 2008 9:27 pm

Post by James » Fri Jan 20, 2012 3:55 pm
Hi Bullitt,

You're right, Internet Sharing won't help you in this instance. You'll need to create a wireless network (from the Mac OS X's Wi-Fi menu icon), and then using something like WaterRoof to share the VPN connection (tun0, tap0, or whatever it may be called).

You'll probably need to give the Mac Mini a static IP on the wireless interface, and then give all other machines connected to its wireless network a static IP addresses in the same range, with the router/gateway set to the Mac Mini's IP.

I'm afraid I don't know of any guides or tutorials for exactly what you are trying to do.

Cheers,
James
James Bekkema
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs

rinku

Posts: 1
Joined: Mon Jul 11, 2011 6:52 am

Post by rinku » Fri Jun 22, 2012 4:35 pm
Old thread but I thought I should post anyway since It appears that someone else but me might find It useful.
I've found a way to manually share a VPN'd connection, I tested sharing my Ethernet connection via Wi-Fi and It worked well.

I couldn't find a way to do It directly through the "Internet Sharing" preference pane, so stuff like DHCP isn't working, and I haven't bothered looking for a way to fix It since I rarely use this setup and when I do It's for sharing with only 1-3 PCs at most, but manually setting IPs works, so that's a start :D

1. First thing to do is to set a fixed IP for the Wi-Fi interface, for example, I used the following configuration:
Code: Select all
IPv4 Address: 10.168.1.10
Subnet Mask: 255.255.0.0
Router: 10.168.1.254
DNS Server: 8.8.8.8 (any DNS of your choice will work)
2. Now connect to your VPN, go to Viscosity's details window and note down the "Client IP" address. I'll call It XX.XX.XX.XX.

3. Now open "/etc/pf.conf" and add the line:
Code: Select all
nat pass on tun0 from 10.168.1.0/24 to any -> XX.XX.XX.XX
- I only tested with tun0, but tap0 should probably work too.
- 10.168.1.0/24 is the same IP range as the Wi-Fi interface, if you changed It to something else, change here accordingly.
- XX.XX.XX.XX is the "Client IP" found following instruction number 2. Mine always change when reconnecting, so I have to repeat this step each time.
- A workaround for the issue above is to use a line like this instead:
Code: Select all
nat pass on tun0 from 10.168.1.0/24 to any -> (tun0)
- This way It will find out the "Client IP" automatically, but there's a catch: this line can't be present in pf.conf at startup because tun/tap is only loaded when Viscosity is opened, thus pfctl will fail to read pf.conf, since tun/tap don't exist (yet).

Place the line as shown below. The pf.conf file will look like this:
Code: Select all
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
nat pass on tun0 from 10.168.1.0/24 to any -> XX.XX.XX.XX
rdr-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
4. Add the line and save, open the Terminal and run:
Code: Select all
sudo pfctl -F all && sudo pfctl -f /etc/pf.conf

sudo sysctl -w net.inet.ip.forwarding=1
6. All done, now when connecting any devices, manually set them like this:
Code: Select all
IPv4 Address: 10.168.1.XX (any IP between 1-254, except whatever you've set in IPv4 Address above, like .10)
Subnet Mask: 255.255.0.0
Router: 10.168.1.10 (same as "IPv4 Address" from instruction 1.)
DNS1: 8.8.8.8 (same as instruction 1)
Hope It helps :)

James

User avatar
Posts: 2076
Joined: Thu Sep 04, 2008 9:27 pm

Post by James » Sat Jun 23, 2012 4:43 pm
Thanks for your contribution rinku!

Cheers,
James
James Bekkema
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs
13 posts Page 2 of 2