‘Oleg Malakhov's blog: OS X, VirtualBox, NAT and static DHCP’

A useful primer on getting NAT set up under OS X using the new packet filter (pf) functionality. Key steps are:

  1. Enable IP Forwarding:

    $ sudo sysctl -w net.inet.ip.forwarding=1

    …or just stick it directly in /etc/sysctl.conf: net.inet.ip.forwarding=1

  2. Add the nat rule for the packet filter, to /etc/pf.conf after the nat-anchor rule:

    nat on en0 from 10.0.0.0/24 to any -> 70.36.235.206
  3. Load rules and enable pf:

    $ pfctl -F all -f /etc/pf.conf -e

    …and make it permanent by editing /System/Library/LaunchDaemons/com.apple.pfctl.plist to add -e to ProgramArguments.

That’s it! You can also check status with:

$ sudo pfctl -s state