Enabling routing and NAT on macOS
Steps: Enable routing on macOS
- Open the Terminal application and enter this command:
sysctl -w net.inet.ip.forwarding=1
Steps: Enable NAT on macOS
- Create a file titled “pf-nat.conf” and add this rule:
nat on en0 from utun0 to any -> (en0)
- Save the pf-nat.conf file.
- Start pfctl using the rule from the pf-nat.conf file.
sudo pfctl -d
#disables pfctlsudo pfctl -F all
#flushes all pfctl rulessudo pfctl -f /Path/to/file/pf-nat.conf -e
#starts pfctl and loads the rules from the pf-nat.conf file