linux – Iptables – Bridge和Forward链

前端之家收集整理的这篇文章主要介绍了linux – Iptables – Bridge和Forward链前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经设置了以太网桥br0,它包含两个接口eth0和tap0
brctl addbr br0
brctl addif eth0
brctl addif tap0
ifconfig eth0 0.0.0.0 promisc up
ifconfig tap0 0.0.0.0 promisc up
ifconfig br0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255

我的默认FORWARD链策略是DROP@H_502_5@

iptables -P FORWARD DROP

当我不添加以下规则时,流量不会通过桥接.@H_502_5@

iptables -A FORWARD -p all -i br0 -j ACCEPT

据我所知,iptables只负责IP层.@H_502_5@

ebtables应负责过滤以太网桥上的流量.@H_502_5@

那么为什么我必须在iptable的FORWARD链中添加ACCEPT规则?@H_502_5@

解决方法

由于br-nf代码可用作linux 2.4的补丁并在linux 2.6中使用:

The br-nf code makes bridged IP
frames/packets go through the iptables
chains. Ebtables filters on the
Ethernet layer,while iptables only
filters IP packets.@H_502_5@

由于你正在使用的流量是ip,iptables规则仍然适用,因为br-nf将桥接数据包传递给iptables.@H_502_5@

This是阅读有关交互的一个很好的资源,this one详细介绍了br-nf代码功能,包括如何禁用所有或部分功能(即不将桥接流量传递给iptables).@H_502_5@

猜你在找的Linux相关文章