How to Disable/Enable IP forwarding in Linux

This article describes how to Disable or Enable an IP forwarding in Linux.

Current IP forwarding status

Read a current state of IP forwarding:

# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

Currently, the output number 1 indicates that the IP forwarding is enabled. The above value is read from the Linux proc file system and more precisely from the actual file /proc/sys/net/ipv4/ip_forward file:

# cat /proc/sys/net/ipv4/ip_forward
1

Disable IP forwarding

To disable IP forwarding on a running Linux system run:

# sysctl -w net.ipv4.ip_forward=0
net.ipv4.ip_forward = 0

The above command actually writes number 0 into the above mentioned file /proc/sys/net/ipv4/ip_forward. If from some reason the above command fails you can attempt to disable the IP forwarding manually by:

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

The above change is not reboot persistent. To permanently disable the IP forwarding on your Linux system edit /etc/sysctl.conf and add the following line:

net.ipv4.ip_forward = 0

转载于:https://www.cnblogs.com/mouseleo/p/9859990.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值