Posted in Linux Red Hat/CentOS

Enable IP forwarding under RHEL/CentOS

June 6, 2006 - 4 comments

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

November 14, 2008 - 9:01

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?

Sébastien Wains

November 17, 2008 - 10:24

Firewall issue ?

John C.Young

February 4, 2010 - 14:55

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.

Before submitting, some rules :
- Is your comment related to the article ?
- You're having a problem ? Have you checked Google, other howtos, docs, manpages ?
- You're still having the problem ? Have you raised log verbosity, checked traces, ran tcpdump ?
- Have you checked your configuratoin for typo ?
Unless your comment is providing additional info or respect the rules above, DON'T comment.
If you don't understand what you are doing, I urge you to read the documentation, I'm not your free Level 1 helpdesk guy.