Home > Operation and Maintenance > Linux Operation and Maintenance > How to enable IP forwarding on Linux

How to enable IP forwarding on Linux

不言
Release: 2019-03-25 15:51:29
Original
4644 people have browsed it

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

How to enable IP forwarding on Linux

Check the current IP forwarding

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

$ cat /proc/sys/net/ipv4/ip_forward

0
Copy after login

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

$ sudo sysctl net.ipv4.ip_forward

net.ipv4.ip_forward = 0
Copy after login

Enable Kernel IP Forwarding

Let us enable IP forwarding for the active shell of our current Linux system. These changes will be lost when the system is shut down or restarted.

$ echo 1 > /proc/sys/net/ipv4/ip_forward
Copy after login

Alternatively, we can use sysctl to enable it

$ sysctl -w net.ipv4.ip_forward=1
Copy after login

Enable kernel IP forwarding (permanent)

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

net.ipv4.ip_forward = 1
Copy after login

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

$ sysctl -p
Copy after login

This article has ended here. For more exciting content, you can pay attention to the linux video tutorial column of the PHP Chinese website!

The above is the detailed content of How to enable IP forwarding on Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template