Skip to content

How To Enable IP Forwarding on Linux

How to Enable IP Forwarding in Linux operating system. Steps to enable kernel ip forwarding in linux system. enable ip forwarding permanently using sysctl

Category
Networking
On this page

For the security purpose by default IP forwarding is disabled in modern Linux operating system. If you are required to enable IP forwarding on your system, follow the below steps. In this article, you will get how to check that IP forwarding is enabled or not. If not, enable it.

Check Current IP Forwarding

Check the value if ip_forward in /proc filesystem as following command.

cat /proc/sys/net/ipv4/ip_forward

0

or we can use sysctl command line to query for kernel values like below command.

sudo sysctl net.ipv4.ip_forward

net.ipv4.ip_forward = 0

Enable Kernel IP Forwarding

Let’s enable the IP forwarding for your current active shell of Linux system. This changes will be lost after a system shutdown or reboot.

echo 1 > /proc/sys/net/ipv4/ip_forward

Or, we can use sysctl to enable it

sysctl -w net.ipv4.ip_forward=1

Enable Kernel IP Forwarding (Permanent)

To enable IP forwarding permanently edit /etc/sysctl.conf and add the following line. This will enable IP forwarding even after the system reboot.

net.ipv4.ip_forward = 1

After adding above values in sysctl.conf, Use following command to reload values of this file.

sysctl -p

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top