Blog Home
Updated: 2023 Feb 05

How to enable IP Forwarding in Linux

Check if IP Forwarding is enabled

sudo sysctl net.ipv4.ip_forward

if the output value is 1, it means it is on. otherwise, we move on to the next step.

Enable IP forwarding

Temporary enable

sysctl -w net.ipv4.ip_forward=1

Permanent enable

open the file /etc/sysctl.conf, use your favourite text editing tool.

sudo emacs /etc/sysctl.conf

add the following line. and save and exit.

net.ipv4.ip_forward=1

save ip forwarind in kernel.

sysctl -p