Skip to contentSkip to conversation

MAC Filtering

DISCUSSION Erwin Van de Velde 3 participants 4 messages Jan 5, 2005 1 message not in the archive netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I'm designing software for a testlab for testing mobility protocols. I use wireless-over-wired links and link down events should be simulated by a blocking firewall on both ends. The nodes only have the source and destination MAC addresses for each link (it is possible that multiple interfaces have the same IP address and that different 'wireless' interfaces have different transmit ranges).
Is it possible to filter on both the source and destination MAC address? I only found the option with source MAC address...
Ebtables is not an option as bridges are needed there.

If not possible with the normal netfilter, is there a patch that can do it? Is it even possible to do such a thing?

Thanks in adv,

Erwin Van de Velde
University of Antwerp
Belgium

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi,

I don't want to bridge, I only said I have to when using ebtables. I need MAC filtering without bridging... I'm fully aware of the fact that iptables works on layer 3 and that MAC is layer 2, however if it can filter on source MAC addresses, why can't it filter on destination MAC addresses?

Best regards,
Erwin

Quoted 9 lines

If you bridge, you cannot use iptables. Ip tables operates on layer 3 (routed) and the destination MAC is always the MAC of the firewall. Ebtables operates on layer 2 (switched) and can filter traffic based on source and destination MAC address.

So I think ebtables is exactly what you need.

HTH,
Martijn Lievaart

#3 lore raw
Quoted 2 lines

if it can filter on source MAC addresses, why can't it filter on destination MAC addresses?

Destination MAC addresses are potentially unknown until after an ARP reply has been received. All iptables processing has already been done before an ARP request is even sent...

best regards
Patrick

#4 lore raw
In reply to Erwin Van de Velde

Op wo, 05-01-2005 te 17:12 +0100, schreef Erwin Van de Velde:

Quoted 6 lines

Hi,

I don't want to bridge, I only said I have to when using ebtables. I need MAC filtering without bridging... I'm fully aware of the fact that iptables works on layer 3 and that MAC is layer 2, however if it can filter on source MAC addresses, why can't it filter on destination MAC addresses?

You can use ebtables without using a bridge as follows:

brctl addbr br0
brctl addif br0 eth0
ifconfig eth0 0.0.0.0
ifconfig br0 $IP_OF_ETH0_SIDE
brctl addbr br1
brctl addif br1 eth1
ifconfig eth1 0.0.0.0
ifconfig br1 $IP_OF_ETH1_SIDE

Change your routing table as needed. Your router thus uses brx instead of ethx to transmit and receive packets. ebtables will see the packets, so you can do
ebtables -A OUTPUT -d $A_MAC_ADDRESS -j <target>

If you only need to check the destination address in one direction, f.e. traffic leaving on eth0, you only need one bridge (in this case only br0), with the proper routing table.

The downside is that your performance will downgrade substantially, because all traffic will be queued twice.

cheers,
Bart