Monday, May 19, 2014: Quick Note: Setting up NAT service on Mac OS X

I wanted to share my Mac’s Internet connection from en2 (Bluetooth PAN) to en1 (Wi-Fi), but didn’t want to run a full-fledged Internet Sharing (DHCP, Wireless Access Point, …).

Thanks to this post, here is the relevant part:

# Enable IP forwarding:
sudo sysctl -w net.inet.ip.forwarding=1

# Kill natd, just in case:
sudo killall -9 natd
sudo killall -9 natd

# Some ipfw rules:
sudo /sbin/ipfw add 100 divert natd ip from any to any via en2

# ...and start the NAT server:
sudo /usr/sbin/natd -interface en2 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface en1

Now, the client should be able to set the Default Gateway to Mac’s IP address and use the Internet through it!