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:
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:
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:
To load the settings that we made to /etc/sysctl.conf file, run the following command:
sysctl -p
That's all..! So simple it was..!
0 comments:
Post a comment