Enable IP forwarding on you Linux router

How to enable IP forward

How do I enable IP forwarding on a Linux router?

People ask me this time and time again so here are 2 short answer.

(if you don’t use IPv6 ignore the lines that contain ipv6 in the content)

Temporarily enable IP forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward ;
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding;

Permanent enable IP forwarding:

echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/999_ip_forward.conf ;
echo "net.ipv6.conf.all.forwarding=1" >> /etc/sysctl.d/999_ip_forward.conf ;
sysctl -p;

More information:

You can check some more information on Redhat documentation.

Please take notice that by enabling IP forward you are accepting that your server will act as an router.
This can be a security issue if your firewall, and in special, the FORWARD iptables chain is not correctly configured.

Cheers,

Pedro Oliveira

Click to access the login or register cheese