I have Ubuntu 10 as router with WAN(eth0) and LAN(eth1). How can I restric eth1 to accept only packets from certain MAC addresses and drop the rest? I am also about to setup DHCP to certain MAC addresses, however, anyone can manually set IP address. I have like 4-6 my own devices which can use the network.
feedback
|
migrated from serverfault.com Mar 8 '11 at 12:14
This question came from our site for system administrators and desktop support professionals.
|
As I mentioned in the comments, I don't think this buys you any real security, or even any more security than blocking based on IP, but something like this should do it:
Assuming, of course, that your default policy is DROP. | |||||||
|
feedback
|
|
( I am user63709; somehow my Google OpenID login and MyOpenID login got split, when it's actually the same in Stack Overflow)
Since you want to "restric [sic] eth1 to accept only packets from certain MAC addresses and drop the rest", you will want a default DROP policy. (BTW, I made a slight mistake in the arptables rules above. They should be:)
(Note again, that | |||||||||
feedback
|
|
Here is a start for you:
All mac addresses other than | |||
feedback
|
|
You might be interested in It's kind of iptables, but specifically for layer 2. Although it can also 'peek' into some L3 information.
Whenever there's a new MAC Address you want to allow, just do | |||
|
feedback
|
|
Michael, you can not specify more than one mac source per rule so you will need a set of rules like the following (if you are going to use iptables)
Note that these are in the FORWARD chain and not the INPUT chain. By having these rules in the FORWARD chain your linux router will not let any mac except your allowed ones to send or receive any traffic through the router. They will still be able to communicate with machines on the same subnet as their own (because that doesn't require them to pass through the router). You can also control who can connect to your router by duplicating the above rules for the input chain.
Reading your comment on one of the other shorter answers about which cases FORWARD and INPUT work with, here is a short explanation. FORWARD only applies to packets going through your router to other subnets or to the outside world (through the WAN) interface. INPUT applies to packets which are destined to terminate on the router itself (eg. SSH connections to the router/linux box itself). | |||
|
feedback
|