How To Enable IP Forwarding On CentOS / RedHat

by lifeLinux on May 11, 2011

By default, Linux distribution such as Redhat, CentOS, and Fedora will have IP Forwarding disabled. The need to forward IP packets from one source to another using linux as the default gateway or linux router, IP forwarding should be enabled from this considerations. There are several techniques to enable IP Forwarding.

Check IP Forwarding status

Type the following command

[root@lifelinux ~]# sysctl -l | grep ip_forward

Sample outputs

net.ipv4.ip_forward = 0

or checking out the value in the /proc system

[root@lifelinux ~]# cat /proc/sys/net/ipv4/ip_forward
0

If IP forwarding is disabled, a value of 0 would be displayed and if IP forwarding was recently enabled, linux should be displaying a numerical value of 1.

Enable IP Forwarding temporarily

Login as root and type the following command

[root@lifelinux ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

The setting is changed instantly but this setting will be erased after the reboot.

Enable IP Forwarding permanently

Type the following command

[root@lifelinux ~]# vi /etc/sysctl.conf

Add the following line

net.ipv4.ip_forward = 1

To enable the changes made in sysctl.conf you will need to run the command

[root@lifelinux ~]# sysctl -p

Related Posts:

Previous post:

Next post: