IPTables rule to filter on ethernet address

ethernetiptables

I've a script to automatically block internet access after 11pm (23:00) and restore it at 6am (06:00). The script adds and remove some drop rules in iptables.

Unfortunately the filtering rule refers to the IP address. Since the user may easily change its ip address by hand he may thus bypass the filter.

The question is if its possible to define an IP table DROP rule that filters on ethernet address ?

PS: I expect an example as answer, not a simple yes or no ! 😉

Best Answer

In short:

iptables -A INPUT -m mac --mac-source 00:0C:F1:6C:CC:7D -j DENY
iptables -A INPUT -m mac --mac-source 00:E0:29:17:7E:78 -j DENY
iptables -A INPUT -m mac --mac-source 00:A0:CC:D4:FE:A7 -j DENY

Perhaps PREROUTING or FORWARD as appropriate for the chain, and ACCEPT not deny if you want a whitelist.

The man page fo iptables is your friend.