Enable IP Forwarding / Routing on Ubuntu 18.04+

Last Updated on

Enabling routing via iptables is slightly different on Ubuntu than Centos / RHEL.  That is explained here in depth using firewalld.  On Ubuntu the same can be accomplished but with iptables, a more traditional routing configuration.  Secondly, we will create some default UFW firewall rules to secure the exposed (uplink) connection while leaving the LAN interface / IP fully open for local connectivity.

1
2
3
sudo iptables -t nat -A POSTROUTING -o enx3c18a00091a6 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o eno1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth1 -o enx3c18a00091a6 -j ACCEPT
1
2
3
4
5
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.2.0/24
sudo ufw default allow FORWARD
sudo ufw allow 22/tcp
Lima

About the author

Lima is the visual nautical indicator for "stop instantly."

Leave a Reply