Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Presently, I limit which clients can access my server by using IP addresses via iptables, only approved IP addresses can connect.

However, the problem with this is if a client is on a laptop and goes to a different location, they can no longer connect because the IP has changed.

For a variety of reasons, iptables authentication is the only option I have.

Is there a way to restrict access by device instead of ip address. For instance, only allow certain MAC address to connect to port 5000.

Is it possible to do this via iptables? Note, the computers are not on the same network, they could be connecting from anywhere in the world.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You can't do this because MAC addresses aren't available to you for connections that have traversed the internet.

To do what you want it would be much safer to setup a VPN and only allow connections via that to your critical infrastructure. If you can't do that then you could try setting up some sort of two factor authentication.

If you really are stuck with just iptables then you may get by with port knocking. There appears to be a fairly good tutorial on this in the Arch Linux wiki but heed the warning and don't use the example ports/sequence in your environment.

A combination of the above would techniques be even better.

share|improve this answer

Iptables has a mac module. You can use it like this:

/sbin/iptables -A INPUT -m mac --mac-source 00:0F:EA:91:04:08 -j DROP

nixCraft has an extensive guide on how to create filter rules based on mac addresses.

But this only works on the same network, as MAC addressing is link-layer specific and won't get forwarded when using routing. So, as long as the devices are on different networks that need routing, this won't work.

share|improve this answer
    
A MAC address over the internet ? –  Iain Jun 28 '13 at 23:10
    
There's no way to do this then for devices on different networks, e.g. MAC address over the internet? –  user788171 Jun 28 '13 at 23:22
    
My fault, unintentionally skipped the last paragraph. Added explanation for that. It may be possible to get it working with a VPN, not sure about that, though.. –  MKzero Jun 28 '13 at 23:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.