How to Enable IP Forwarding in Linux

For the security reason of course IP sending is disable in modern Linux operating systems. If you want to enable IP forwarding on your system, take after the beneath steps. In this article we will show you how to check if IP forwarding is enabled or not . If not, how to do it.

Check Kernel IP Forwarding

Check the value of ip_forward in /proc filesystem with the following command:

$ cat /proc/sys/net/ipv4/ip_forward
0

Or we can use sysctl command line to query for Kernel values like below command:

$ sysctl net.ipv4.ip_forward 
net.ipv4.ip_forward = 0

Enable kernel IP forwarding temporary:

Let’s enable ip forwarding for your current running session in Linux. This changes will lost after a system reboot.

echo 1 > /proc/sys/net/ipv4/ip_forward

Or, we can use sysctl to enable it

$ sysctl -w net.ipv4.ip_forward=1

Enable Kernel IP Forwarding Permanently

To enable IP forwarding permanently, edit /etc/sysctl.conf and add following line. This will enable ip forwarding even after reboot.

net.ipv4.ip_forward = 1

After adding above values in sysctl.conf, Use following command to reload values of this file.

$ sysctl –p