Networking on mac can be tricky, the same applies to NAT. If we want our mac to act as NAT we need:
- Enable forwarding
sudo sysctl -w net.inet.ip.forwarding=1
- Create a file with our NAT rules for eg
nat_rules
with our configuration
nat on en0 from en1 to any -> (en0)
- 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