This is a basic filter configuration which will only let frames made by
the protocols IP version 4 and ARP through. Also, the network has some
old machines that use the protocol field of the Ethernet frame as a length
field (they use the Ethernet 802.2 or 802.3 protocol). There was no reason
not to let those machines through, more precisely: there was a reason to let
them through ;-). So, those frames, with protocol LENGTH denoting that it's
really a length field, are accepted. Of course one could filter on the MAC
addresses of those old machines so no other machine can use the old Ethernet
802.2 or 802.3 protocol. All other frames get logged and dropped. This
logging consists of the protocol number, the MAC addresses, the ip/arp info
(if it's an IP/ARP packet of course) and the in and out interfaces.
If you don't absolutely need to let those old machines (using the 802.2 or
803.2 Ethernet protocol) through the bridge, don't let them. Opening it up
with the
actually
breaches security if you're filtering IP bridge traffic with iptables: IP
traffic passing the bridge using the 802.2 or 802.3 Ethernet protocol
won't get filtered by iptables (it's on the todo list).
ebtables -A FORWARD -p IPv4 --ip-src 172.16.1.4 -s ! 00:11:22:33:44:55 -j DROP
This is an anti-spoofing filter rule. It says that the computer using IP
address 172.16.1.4 has to be the one that uses ethernet card
00:11:22:33:44:55 to send this traffic.
Note: this can also be done using iptables. In iptables it would look like this:
iptables -A FORWARD -s 172.16.1.4 -m mac --mac-source ! 00:11:22:33:44:55 -j DROP
The difference is that the frame will be dropped earlier if the ebtables rule
is used, because ebtables inspects the frame before iptables does. Also note
the subtle difference in what is considered the default type for a source
address: an IP address in iptables, a MAC address in ebtables.
If you have many such rules, you can also use the
among
match to
speed up the filtering.
ebtables -N MATCHING-MAC-IP-PAIR
ebtables -A FORWARD -p IPv4 --among-dst 00:11:22:33:44:55=172.16.1.4,00:11:33:44:22:55=172.16.1.5 \
-j MATCHING-MAC-IP-PAIR
We first make a new user-defined chain
MATCHING-MAC-IP-PAIR
and we send all
traffic with matching MAC-IP source address pair to that chain, using the
among
match. The filtering in the
MATCHING-MAC-IP-PAIR
chain can then assume that the
MAC-IP source address pairs are correct.