For the security purpose by default IP forwarding is disabled in modern Linux operating system. If you are required to enable IP forwarding on your system, follow the below steps. In this article, you will get how to check that IP forwarding is enabled or not. If not, enable it.

Check Current IP Forwarding

Check the value if ip_forward in /proc filesystem as following command.

cat /proc/sys/net/ipv4/ip_forward


or we can use sysctl command line to query for kernel values like below command.

sudo sysctl net.ipv4.ip_forward

net.ipv4.ip_forward = 0

Enable Kernel IP Forwarding

Let’s enable the IP forwarding for your current active shell of Linux system. This changes will be lost after a system shutdown or 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 (Permanent)

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

net.ipv4.ip_forward = 1

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

sysctl -p