Today I Learned

Setup NAT on mac

Networking on mac can be tricky, the same applies to NAT. If we want our mac to act as NAT we need:

1) Enable forwarding

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

2) Create a file with our NAT rules for eg nat_rules with our configuration

nat on en0 from en1 to any -> (en0)

3) Start PF via pfctl

sudo pfctl -d                     # stop pfctl
sudo pfctl -F all -f ./nat_rules  # flush all rules and load new ones
sudo pfctl -e                     # start pfctl