User Tools

Site Tools


Sidebar

Go Back

Contact
Recent Changes
Sitemap
macos:setup_nat

Setup NAT on macOS

Enable IP forwarding on OSX

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

Edit /etc/pf.conf file. Forward packets from 192.168.1.0/24 to en0

scrub on en0 reassemble tcp no-df random-id
nat on en0 from 192.168.1.0/24 to any -> en0

Load PF config

# Disable PF if it was enabled before
sudo pfctl -d
# Enable PF and load the config
sudo pfctl -e -f /etc/pf.conf

Setup IP and gateway on client ( Linux )

sudo ip addr add 192.168.1.1 dev eth0
sudo ip route add default via 192.168.1.2
macos/setup_nat.txt · Last modified: 2021/08/26 14:42 (external edit)