Posted in Linux Red Hat/CentOS
Enable IP forwarding under RHEL/CentOS
The regular way
Edit /etc/sysctl.conf
Edit the “net.ipv4.ip_forward” line and set it to 1
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
When done type the following to validate the new setting :
sysctl -p
The manual way :
echo "1" > /proc/sys/net/ipv4/ip_forward
This wouldn’t be persistent though, so you should edit sysctl.conf anyway, or add the command in /etc/rc.local
A great guide : http://www.ducea.com/2006/08/01/how-to-enable-ip-forwarding-in-linux/
Comments
widyartono
I follow your tutorial to forward IP under CentOS. It’s work when I used 2 NIC, but when I try to used 4 NIC it’s not work. what happen with my router? do you have answer for my problem?
John C.Young
Thanks, this came in handy when our Cisco 6509 was down for an hour or so during a period of low traffic on our network. I was able to static routing on a dual core Pentium D of approximately 400MB without a problem.
Nice!
Regards,
John C. Young
Managing Director
Internet Gateway of South Beach
http://www.igsobe.com
Leave Comment
Please consider visiting the partners below if you enjoyed this article :If this post saved you time and money, please consider checking my Amazon wishlist.







Sébastien Wains » Routed OpenVPN between two subnets behind NAT gateways
[...] follow http://www.wains.be/index.php/2006/06/06/enable-ip-forward-under-rhelcentos/ (which works for Debian as [...]