Pages

Sunday, December 2, 2012

How to Enable IP Forwarding Under Ubuntu/Linux Mint



In this tutorial, we will see how to enable IP Forwarding under Ubuntu/Linux Mint. IP Forwarding is required when users want to make their computers act as a router, gateway, DMZ, VPN server, and it is also used in internet connection sharing.

Getting Started

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


sysctl net.ipv4.ip_forward

If it is disabled, you will get this output:

net.ipv4.ip_forward = 0

Enabling IP Forwarding Temporarily

To enable IP Forwarding temporarily, run these commands:

sudo su 
echo 1 > /proc/sys/net/ipv4/ip_forward

or

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

Re-check again the status of IP Forwarding with this command:

sysctl net.ipv4.ip_forward

If it is enabled, you will get this output:

net.ipv4.ip_forward = 1

However, IP Forwarding will be disabled once you reboot your system. For a permanent configuration, see below.

Enabling IP Forwarding Permanently

Open the terminal and edit the /etc/sysctl.conf file with this command:

sudo gedit /etc/sysctl.conf

Search and uncomment this line:

net.ipv4.ip_forward = 1


Save your file and exit, then run this command:

sudo sysctl -p /etc/sysctl.conf

NOTE: This tip is workable for Ubuntu 12.10/12.04/11.10 and Linux Mint 14/13 or older.