IP forwarding lets a Linux server pass packets between network interfaces. It is needed for some routers, gateways and VPN servers, but enabling it alone does not configure routes, firewall rules or address translation.

Check the current settings

sysctl net.ipv4.ip_forward
sysctl net.ipv6.conf.all.forwarding

A value of 1 enables forwarding; 0 disables it.

Enable forwarding temporarily

With administrative access, enable only the protocols your network needs:

sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv6.conf.all.forwarding=1

These runtime changes do not make the settings persistent. A restart or another network configuration process can replace them.

Make the settings persistent

On a distribution using sysctl.d, create or edit /etc/sysctl.d/99-ip-forwarding.conf. Retain any existing settings and add the required lines:

net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

Apply this file:

sudo sysctl -p /etc/sysctl.d/99-ip-forwarding.conf

Check the values again and test the intended network path. Conflicting settings in other files or network management software may override them at startup.

To undo the change, restore the previous persistent configuration and runtime values, then verify connectivity.