How to Convert Your Linux Server into a Simple Router
Configuring IP Forwarding
For your Linux server to become a router, you have to enable packet forwarding. In simple terms packet forwarding enables packets to flow through the Linux box from one network to another. The Linux kernel configuration parameter to activate this is named net.ipv4.ip_forward
and can be found in the file /etc/sysctl.conf
. Remove the "#" from the line related to packet forwarding.
Before:
# Disables packet forwarding
net.ipv4.ip_forward=0
After:
# Enables packet forwarding
net.ipv4.ip_forward=1
This enables packet forwarding only when you reboot at which time Linux will create a file in one of the subdirectories of the special RAM memory-based /proc
filesystem. To activate the feature immediately you have to force Linux to read the /etc/sysctl.conf
file with the sysctl command using the -p
switch. Here is how it's done:
[root@bigboy tmp] sysctl -p
sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
kernel.sysrq = 0
kernel.core_uses_pid = 1
[root@bigboy tmp]#