Check Linux IP Forwarding for Access Server Routing⁠

Question: What is IP forwarding, and how do I enable it on Linux?

Answer:

IP forwarding allows a system to route traffic between networks. An example use is a system sitting between two different networks that needs to pass traffic between them.

On most Linux systems, you can turn on IP forwarding by editing the /etc/sysctl.conf file. For example, follow these steps on Ubuntu/Debian:

  1. Connect to the console and get root privileges.

  2. Open the sysctl.conf file in the nano text editor:

    nano /etc/sysctl.conf
  3. Uncomment or add this line:

    net.ipv4.ip_forward=1
  4. Press CTRL_x, Y, then ENTER to save and exit the file.

  5. Run this command:

    sysctl -p
    • You've turned on IP forwarding.