IP forwarding is also known as routing.
If the Linux server is acting as a firewall, router, or NAT device, it will need to be capable of forwarding packets that are meant for other destinations (other than itself).
Linux uses the net.ipv4.ip_forward kernel variable to toggle this setting on or off.
sysctl net.ipv4.ip_forward
returns:
net.ipv4.ip_forward = 0
NOTE: This shows the net.ipv4.ip_forward kernel setting is 0, which means it is off.
cat /proc/sys/net/ipv4/ip_forward
returns:
0
sysctl -w net.ipv4.ip_forward=0 or sysctl -w net.ipv4.ip_forward=1
WARNING: This will not make the change persistent.
Change the setting inside /proc/sys/net/ipv4/ip_forward to turn the setting on or off.
echo 0 > /proc/sys/net/ipv4/ip_forward or echo 1 > /proc/sys/net/ipv4/ip_forward
WARNING: This will not make the change persistent.
To make sure the new setting survives a reboot, edit the /etc/sysctl.conf file.
Add one of the following lines to the bottom of the file, depending on whether to have IP forwarding on or off.
net.ipv4.ip_forward = 0 or net.ipv4.ip_forward = 1
Then, save your changes to this file.
NOTE: The setting will be permanent across reboots.
sysctl -p
Check the status of sysctl with this command:
systemctl status sysctl
The service should say that it is active. If not, start the service with this command:
sudo systemctl start sysctl
On non-systemd Linux installs, checking the status of sysctl will be different. Try:
rc-service sysctl status
If IP forwarding is successfully enabled (verified by checking the kernel variable after reboot), but traffic is still not being received on destination systems, check the FORWARD rules of iptables.
iptables -L -v -n
returns:
... Chain FORWARD (policy ACCEPT 667 packets, 16724 bytes) pkts bytes target prot opt in out source destination
NOTE: The FORWARD chain should either be set to ACCEPT, or have rules listed that allow certain connections.