A router is a key device in network communication. Linux systems are commonly configured as routers. Router configuration is an important skill for Ubuntu administrators.
To configure Ubuntu as a router, all you need to do is configure a kernel variable. The following command confirms the default for IPv4 addressing, where Linux is not configured as a router:
$ cat /proc/sys/net/ipv4/conf/default/forwarding 0
If the local computer has two or more network cards, you can configure the system as a router. To do so, enable IP forwarding in /etc/sysctl.conf with the following directive:
Of course, if IPv6 networking is active, you'll also want to add the following directive:
This is different from the command in comments in the default version of the / etc/ sysctl .conf configuration file. (For more information, see Debian bug 469557 at http://bugs .debian.org.) But the associated variable file, /proc/sys/net/ipv6/ip_forward, does not exist. Interestingly enough, when the net.ipv4.ip_forward variable is set to 1, the net.ipv4.conf.all.forwarding variable is also set to 1.
You don't need to reboot to activate these changes; the following command rereads the /etc/sysctl.conf configuration file:
Finally, to confirm the changes, run the following commands:
$ cat /proc/sys/net/ipv4/ip_forward $ cat /proc/sys/net/ipv6/conf/all/forwarding
Be aware that the directive in /etc/sysctl.conf and the associated file in the /proc directory has varied in the past with Ubuntu releases, so don't be surprised if the directive changes again. Refer to the current /etc/sysctl.conf file for the latest information.
Was this article helpful?