Skip to content

Instantly share code, notes, and snippets.

@vimagick
Last active January 10, 2025 03:47
Show Gist options
  • Save vimagick/864a0ba0282c165641c3d19acdbf1e7f to your computer and use it in GitHub Desktop.
Save vimagick/864a0ba0282c165641c3d19acdbf1e7f to your computer and use it in GitHub Desktop.
Enable LAN Access from Wireguard Peers
#!/bin/bash
# enable ip forwarding
sudo sysctl -w net.inet.ip.forwarding=1
# disable pf firewall
sudo pfctl -d
# flush nat rules
sudo pfctl -F nat
# add NAT rule (utun12 is the wireguard interface, alternatively CIDR can be used here)
echo "nat on en0 inet from utun12:network to any -> (en0)" | sudo pfctl -f -
# list nat rules
sudo pfctl -s nat
# enable pf firewall
sudo pfctl -e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment