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

Linux subnets isolation

· 52CE 我爱测

I have following configuration on my system | br0 (lan0 to lanX + WiFi Home SSID) ethX(internet) - | br1 (WiFi Guest SSID). I need to have both bridges access the internet (nat'ed via ethX) but isolated one each other. I would ex…

问题原文

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

I have following configuration on my system

                   | br0 (lan0 to lanX + WiFi Home SSID) 
ethX(internet) -     
                   | br1 (WiFi Guest SSID). 

I need to have both bridges access the internet (nat'ed via ethX) but isolated one each other.

I would expect that by default routing between bridge interfaces will not be enabled, but it doesn't seem to be a case and I can ping from my guest network to home network.

I think I can use iptable to block traffic from br0 to br1, but I hope to find a more elegant solution that will allow routing only to an upstream interface without the need to configure special rules for each subnet I add to the system.

Is any available? I will be ok using iptables as well but hope that I can setup a positive rule i.e., routing toward ethX allowed rest is blocked.

Thanks, Ilya.

已采纳解答

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

The best way is to drop everything first, then allow forwarding on the interface combination(s) you want, eg:

iptables -F FORWARD
iptables -P FORWARD DROP
iptables -A FORWARD -i br0 -o br1 -s 192.168.1.0/24 -j ACCEPT

.. and so on. The setup above allows your trusted network br0 to reach the untrusted br1, but not the other way around. Any more interfaces you add to the system won't be able to forward unless you specifically add them to the list above. If you want br0 to be able to forward everywhere, do it like this:

iptables -A FORWARD -i br0 -j ACCEPT

All networks should still be able to go out your NAT interface ethX.

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

资料来源与适用范围

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

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

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