Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of enabling IP forwarding on Linux

Shulou Source: shulou.com Published: 2022-06-02 04:36:10 10月05日 Update

This article is about how to enable IP forwarding on Linux. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

For security reasons, IP forwarding is disabled by default in modern Linux operating systems. If you need to enable IP forwarding on the system, perform the following steps. In this article, you will learn how to check if IP forwarding is enabled. If not, how to enable it.

Check current IP forwarding

Use the following command to check the value of the ip_forward in/proc file system.

$cat / proc/sys/net/ipv4/ip_forward0

Or we can use the sysctl command line to query kernel values, such as the following command.

$sudo sysctl net.ipv4.ip_forwardnet.ipv4.ip_forward = 0

Enable kernel IP forwarding

Let's enable IP forwarding for the active shell of the current Linux system. These changes are lost when the system is shut down or rebooted.

$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 enables IP forwarding, even after a system reboot.

Net.ipv4.ip_forward = 1

After adding the above values to sysctl.conf, reload the values of this file using the following command.

$sysctl-p Thank you for your reading! So much for the method of enabling IP forwarding on Linux. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Tags: Systems commands kernels checks methods contents files articles more permanent good practical security operating systems steps see knowledge articles facets references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Redmi Docker Shulou Tech Info