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 Kernel IP Forwarding
Check the value if ip_forward in /proc filesystem as following command.
or we can use sysctl command line to query for kernel values like below command.
sudo sysctl net.ipv4.ip_forwardnet.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