The ip_forward flag enables or disables routing of packets on your CentOS server. To enable forwarding, set ip_forward to true or “1”, and to disable set to “0”.
The flag can be set globally or individually on interfaces. To see if it’s enabled globally check the value under the /proc filesystem.
cat /proc/sys/net/ipv4/ip_forward
To enable ip_forward.
echo "1" > /proc/sys/net/ipv4/ip_forward
To disable ip_forward.
echo "0" > /proc/sys/net/ipv4/ip_forward
Set ip_forward permanently in sysctl.conf
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g'/etc/sysctl.conf;
Check if IP forwarding is enabled for eth0 (for other interfaces, simply replace eth0 with your interface).
cat /proc/sys/net/ipv4/conf/eth0/forwarding
Enable IP forwarding on eth0.
echo "1" > /proc/sys/net/ipv4/conf/eth0/forwarding
Disable IP forwarding on eth0.
echo "0" > /proc/sys/net/ipv4/conf/eth0/forwarding
Comments