Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to manage filtering by MAC in Ubuntu?


  1. Ubuntu DHCP is configured and working (network

    a) Laptop 1 is set in configuration on Ubuntu as static IP

  2. Laptop 1 is configured for automatic IP and when is connected to server everything works.

  3. I'm taking laptop 2 which is configured as static IP and his configuration is not set in Ubuntu dhcpd.conf

  4. After laptop 2 is connected internet working.

It is possible to do MAC filtering which disallow to connect PCs with address IP set as static but MAC address is not configured in Ubuntu (something like: intruder in network)?

share|improve this question

You can configure your DHCP server to only give static addresses to known MACs. Any unknown MAC addresses which attempt to get an address via DHCP will be logged as denied.

You can specify a dynamic address range to allocate to unknown addresses. These won't be static though, so any MAC which connects multiple times won't necessarily have the same IP. However, simply not allowing dynamic IP allocation, and only using static IPs for known MAC addresses is the easiest/best solution to what (I think) you are asking.

If it is WiFi, look into using the built-in MAC filtering on your access points or routers. If it is for wired ethernet, then you'll need to build a bit more complex firewall rules to deal with it. Though, for some things, these too can simply be subverted.

share|improve this answer
I have dynamic configuration OFF and only one adrress configured in dhcpd.conf. But thats not working for me. Still second laptop with different MAC can (after add static IP in his configuration) has internet. – user1655161 Sep 29 '12 at 19:25
Are you sure that dhcpd is the DHCP server your clients are connecting to? I'm using dnsmasq as my DHCP and DNS server, and it works fine here. Make sure your wifi router isn't serving DHCP, or that you aren't also running a different DHCP server which is giving out the addresses. – dobey Sep 29 '12 at 19:39
Because its my first steps in ubuntu I my free time I try to reinstall server and try again. – user1655161 Oct 2 '12 at 15:40
Im tried ones again, but seems the problem is when client configured his PC to static adress from even if configuration on ubuntu DHCP is set to static. When client has static manualy enter in example windows configuration, he gets internet on his PC. – user1655161 Oct 27 '12 at 10:50

You probably want to have a firewall filter to only allow specific internet access. something like this:

sudo iptables -A INPUT -p tcp --dport 80 -m mac --mac-source "Mac_address" -j ACCEPT

sudo iptables -A INPUT -p tcp --dport 443 -m mac --mac-source "Mac_address" -j ACCEPT

sudo iptables -A INPUT -j DROP

Order matters above. Allow before to deny.

This was taken and modified from the following: filtering MAC address in ufw and also: IptablesHowTo. Please read these websites.

Your DHCP server is not a firewall and mostly manages how to hand out IP info, it's related information, and supplemental path to clients if they want it. Thank you. Good day.

share|improve this answer

Your Answer


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.