Linux IP Forwarding - How to enable/disable IPv4 forward

This article describes how to permanently enable IPv4 forwarding on a Linux-based system.

In many situations it is necessary to allow IP packets to be forwarded on the Linux system. For this use case there are countless software which need this option.

Is IPv4 forwarding already enabled?

You can check the ip forward status with following command.

cat /proc/sys/net/ipv4/ip_forward
## 0 = disabled
## 1 = enabled

How can I turn on forwardining temporarily?

With these options, the setting is reset after a system restart.

sysctl -w net.ipv4.ip_forward=1
OR
echo 1 > /proc/sys/net/ipv4/ip_forward

How do I enable IPv4 forwarding permanently?

nano /etc/sysctl.conf
## EDIT LINE TO ##
net.ipv4.ip_forward = 1
## SAVE FILE ##

## To reload sysctl ##
sysctl -p