Written by Guillermo Garron .
Date: 2011-01-23 14:36:30 +0000
If you want to use a Linux Operating System driven box, to act as a router or gateway, you need IP packets to pass through your Linux box. By default packets not directly addressed to a Linux powered PC will be discarded, so you need to enable IP Forwarding.
This can be done in different ways, and we’ll check here some of the most common.
This is maybe the most used way, it is a temporary change, and you need to enable it after every reboot.
echo 1 > /proc/sys/net/ipv4/ip_forward
You can add this line to /etc/rc.local file, and that way, each time you reboot your computer it will be enabled again.
You can check if IP forwarding is enabled or disabled by checking the content of /proc/sys/net/ipv4/ip_forward file
If the output is 1, it is enabled if 0, then it is disabled.
sysctl let’s you change Kernel values on the fly, so you can use it, to change the IP forward behaviour of your Linux.
First, let’s check if it is enabled or disabled, as root run:
sysctl -a | grep net.ipv4.ip_forward
Now you can set its value to 1, to enable ip forwarding.
sysctl -w net.ipv4.ip_forward=1
This is also temporary, if you want it to be permanent, you can edit the file /etc/sysctl.conf
And modify or add this line:
net.ipv4.ip_forward = 1
Now let Linux load the changes you’ve made.
You’re done, now you have IP forward enabled on your Linux, you can now proceed to configure your Linux router or Linux gateway.
This works for Ubuntu, Debian, Fedora, Slackware or any other Linux distribution
If you liked this article please share it.permalink
If you enjoyed the article, please share it
My name is Guillermo Garron. I am telecommunications engineer from Bolivia
I like technology a lot, and this site is mainly dedicated to that
Posts via email
If you use the letter icon above and subscribe to my tinyletter newsletter, you will get one to two emails, related to this site, or not. If what you want is to get the posts of this site via email, use the form below