Skip to content
Discussion options

You must be logged in to vote

This solved the issue (on gateway node)

sudo iptables -t nat -A POSTROUTING -o <client_interface> -j MASQUERADE

Step-by-Step UFW-Compatible NAT Setup

  1. Enable IP Forwarding
echo "net.ipv4.ip_forward=1" | sudo tee /etc/ufw/sysctl.conf
sudo sysctl -p /etc/ufw/sysctl.conf
  1. Add NAT Rule to UFW’s before.rules
    Edit UFW’s IPv4 pre-routing config:
    sudo nano /etc/ufw/before.rules

Scroll to the top, and before the *filter section, add the following:

*nat
:POSTROUTING ACCEPT [0:0]

# NAT rule for VPN or forwarded traffic
-A POSTROUTING -o eth0 -j MASQUERADE

COMMIT
  1. Allow Forwarding in UFW
    Edit the main UFW config:
    sudo nano /etc/default/ufw

Set:
DEFAULT_FORWARD_POLICY="ACCEPT"

  1. Reload UFW to Ap…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@sanbroz
Comment options

@dmesad
Comment options

@sanbroz
Comment options

@sanbroz
Comment options

Answer selected by sanbroz
@dmesad
Comment options

@sanbroz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants