Firewall with iptables using mac address filtering in linux !

Posted: August 29, 2009 in linux security, linux server
Tags:

http://www.liberiangeek.net/wp-content/uploads/2009/08/Comodo_Firewall_Pro_logo.pngThere are times when you might need to filter the traffic on your firewall using MAC addresses instead of IP addresses, iptables has the option to do it.

From the man page of iptables:

Note that this only makes sense for packets coming from an Ethernet device and entering the PREROUTING, FORWARD or INPUT chains.

You may want to insert this line in you firewall script.

iptables -A INPUT -m mac --mac-source 00:11:2f:8f:f8:f8 -j DROP

This way the packets comming from the network element with the MAC address 00:11:2f:8f:f8:f8 will be denied.

That is if you want to block the incoming packets to the firewall, but the blocked machine may still be able to send packets across the firewall, so to block those packets, you may want to add also this line.

iptables -A FORWARD -m mac --mac-source 00:11:2f:8f:f8:f8 -j DROP
Comments
  1. Roberto says:

    Hello
    One question? if instead of blocking the mac address I would like to assign 100 k bps to this mac address? how would be the this configuration?

    And where I have to put this line into my ubuntu server 9.10 in order it take effect.

    Thanks.

  2. And if I want to assign bandwith by Mac Address what could be the way to do it?
    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s