大网数据广告活动
服务器运维问答

How to block all traffic between two interfaces?

· 52CE 我爱测

Let's say I have two interfaces on one host, eth0 and eth1. The behavior I'm seeing currently is: Receive traffic on eth0, it finds a suitable route on eth1 and tries to send it. I'm already intercepting the packets coming in on …

问题原文

原帖链接 · blurb · CC BY-SA 3.0

Let's say I have two interfaces on one host, eth0 and eth1. The behavior I'm seeing currently is:

Receive traffic on eth0, it finds a suitable route on eth1 and tries to send it.

I'm already intercepting the packets coming in on eth0 so I would like to stop this forwarding and drop all packets coming in on eth0 instead of sending them on eth1.

In essence, I'd like to block all traffic between two interfaces on one host. Is this possible with iptables or routing?

社区高分解答

原帖链接 · BillThor · CC BY-SA 4.0

You should be able to control this at the kernel level with sysctl. Setting the net.ipv4 and/or net.ipv6 forwarding values off.

net.ipv4.conf.all.forwarding = 0
net.ipv4.conf.eth0.forwarding = 0
net.ipv4.conf.eth1.forwarding = 0

Depending on the distribution you can configure this at startup by editing /etc/sysctl.conf or adding a file in /etc/sysctl.d. Normally forwarding is disabled by default, so you may have a line enabling forwarding.

Some firewall builders will enable or disable forwarding depending on the configuration.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。