Answer the question
In order to leave comments, you need to log in
Packet filtering in bridge (iptables,ebtables)
The question is primarily addressed to Linux system administrators.
There is a PowerPC-based router board that runs under the OpenWRT (Linux) operating system. This board has only two network interfaces eth0 and eth1, combined into a network bridge.
[email protected]:/# brctl show bridge name bridge id STP enabled interfaces br-br0 8000.7e0410820000 no eth0 eth1
Answer the question
In order to leave comments, you need to log in
1. In order to be able to filter traffic passing through the bridge using iptables, you must set the following sysctl system variables:
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
And so, a detailed test report.
From the iron, a couple of voice gateways were at hand, which will be used as end devices (addresses 192.168.253.1 and 192.168.253.2), and a managed switch. We push each of the addpacks into a separate vlan, configure the binding of ports to vlans on the switch and start the experiment.
1. We create a bridge interface and two vlans on a typewriter, push the vlans into the bridge, raise everything, write the address on the bridge interface:
brctl addbr br0
ip l add l eth2 name eth2.10 type vlan id 10
ip l add l eth2 name eth2.11 type vlan id 11
ip l s up dev br0
ip l s up dev eth2.10
ip l s up dev eth2.11
ip a add 192.168.253.3/29 dev br0
sysctl -w net.bridge.bridge-nf-call-iptables=0
sysctl -w net.bridge.bridge-nf-filter-vlan-tagged=0
test-addpac-1# ping 192.168.253.2
PING 192.168.253.2 (192.168.253.2): 56 data bytes
64 bytes from 192.168.253.2: icmp_seq=0 ttl=64 time=10 ms
64 bytes from 192.168.253.2: icmp_seq=1 ttl=64 time=10 ms
64 bytes from 192.168.253.2: icmp_seq=2 ttl=64 time=10 ms
64 bytes from 192.168.253.2: icmp_seq=3 ttl=64 time=10 ms
--- 192.168.253.2 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss'
round-trip min/avg/max = 10/10/10 ms
test-addpac-1# ping 192.168.253.3
PING 192.168.253.3 (192.168.253.3): 56 data bytes
64 bytes from 192.168.253.3: icmp_seq=0 ttl=64 time=15 ms
64 bytes from 192.168.253.3: icmp_seq=1 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=2 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=3 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=4 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=5 ttl=64 time=5 ms
--- 192.168.253.3 ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss'
round-trip min/avg/max = 5/6/15 ms
sysctl -w net.bridge.bridge-nf-call-iptables=1
iptables -A FORWARD \
--src 192.168.253.1 --dst 192.168.253.2 \
-j DROP
test-addpac-1# ping 192.168.253.2
PING 192.168.253.2 (192.168.253.2): 56 data bytes
--- 192.168.253.2 ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss'
test-addpac-1# ping 192.168.253.3
PING 192.168.253.3 (192.168.253.3): 56 data bytes
64 bytes from 192.168.253.3: icmp_seq=0 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=1 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=2 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=3 ttl=64 time=5 ms
64 bytes from 192.168.253.3: icmp_seq=4 ttl=64 time=5 ms
--- 192.168.253.3 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss'
round-trip min/avg/max = 5/5/5 ms
[email protected]:~$ sudo iptables -L FORWARD 8 -n -v
455 38220 DROP all -- * * 192.168.253.1 192.168.253.2
iptables -A FORWARD -m physdev \
--physdev-in eth2.10 --physdev-out eth2.11 \
--src 192.168.253.1 --dst 192.168.253.2 \
-j DROP
ebtables -A FORWARD -p ip \
--ip-source 192.168.253.1 --ip-destination 192.168.253.2 \
-j DROP
You have to understand the levels at which iptables and ebtables work - this is the time.
in the bridge (L2) - you need to work with MAC addresses.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question