Skip to content

How To Enable IP Forwarding With UFW

  • by


I’ve just spent the last hour trying to get IP forwarding to work with UFW nicely on Ubuntu. So in the interests of the common good, and so I can find it next time, I’m posting the answer here.

The problem is simple, when UFW enabled IP forwarding doesn’t work and you get frustrated trying to find a firewall rule that will actually make it work. The fix is pretty simple too, there are two files to update:

sudo vim /etc/default/ufw

# Set the default forward policy to ACCEPT, DROP or REJECT. Please note that # if you change this you will most likely want to adjust your rules DEFAULT_FORWARD_POLICY="ACCEPT"

sudo vim /etc/ufw/sysctl.conf

# Uncomment this to allow this host to route packets between interfaces 

Restart UFW (sudo service ufw restart) and you should hopefully have working IP forwarding :)

 3,111 total views,  1 views today