Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks



Thursday, 26 September 2013

How To : Enable IP Forwarding in Ubuntu/Linux Mint

ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux,

IP Forwarding is mostly needed when you are working on two ethernet interfaces, when you need to configure your system as a router or a gateway, when you want your system to act as VPN server, and for sharing the internet connection. We have already used IP forwarding concept in one of our articles entitled How To: Configure Ubuntu as a Router. In this article,we will learn how IP Forwarding is enabled in systems running Ubuntu/Linux Mint.

Enabling IP Forwarding

To check whether IP Forwarding is previously activated or not, use the following command:

sysctl net.ipv4.ip_forward

In case it is disabled, you should get following output:

net.ipv4.ip_forward = 0

Output:

ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux,

Enable IP Forwarding Temporarily

To enable IP Forwarding temporarily, you can use any of the following commands:

sudo -i
echo 1 > /proc/sys/net/ipv4/ip_forward

or

sudo -i
sysctl -w net.ipv4.ip_forward=1

To check whether IP Forwarding is enabled or not, you can use following command:

sysctl net.ipv4.ip_forward

You should get following output, if it is enabled:

net.ipv4.ip_forward = 1

Output:

ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux,

Enable IP Forwarding Permanently

To keep IP Forwarding enabled permanently, you will have to edit /etc/sysctl.conf file using your favorite text editor, I will use gedit here.

sudo gedit /etc/sysctl.conf

You will find a line which says:

# net.ipv4.ip_forward = 1

You need to uncomment this line to enable IP Forwarding, so that it reads:

net.ipv4.ip_forward = 1

Output:

ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux,


To load the settings that we made to /etc/sysctl.conf file, run the following command:

sysctl -p

ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux, ip-forwarding-in linux,


That's all..! So simple it was..!


0 comments:

Post a Comment