We can easily determine whether IP Forwarding is enabled or not to execute the below command if the output will be shown 1 the IP_FORWARED is enabled in your system.
cat /proc/sys/net/ipv4/ip_forward
0
Another method is to check the status,
sysctl -a | grep net.ipv4.ip_forward
net.ipv4.ip_forward = 0
How to Enabled ip_forward:
Open the the sysctl.conf and enable IPforwarding
vim /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
change to
net.ipv4.ip_forward = 1
:wq!
save and quit.
Your changes take effect immediately run a below command
sysctl -p /etc/sysctl.conf
or
sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
Save the configuration :
sysctl -w
If you need change the ip forward temporary, execute the command to enable it after every reboot.
echo 1 > /proc/sys/net/ipv4/ip_forward
Comments (0)