Firewalling MAC addresses



  • This post may be of interest to the OP and others:
    https://forum.pfsense.org/index.php?topic=116291.msg644789#msg644789
    Javier is doing some cool stuff, but most of it seems to happen on the Spanish board. I'm glad he shared this with us.



  • What would be interesting, at least to me, is to understand why you would want to implement FW rules based on MAC address. This is something I don't understand yet

    To ensure a device cannot get out, no matter what it's IP address.  Filtering on incoming MACs would be pretty much useless though, as you'll only see the MAC for the ISPs router.



  • Routers only route between Layer 3 (IP addresses).

    pfSense is also a firewall and can filter on layer 4 (TCP & UDP ports etc.) as well as 3.  Other firewalls have no problem filtering on MAC addresses.  For example, for many years I used the firewall in openSUSE.  It could filter on MACs, as can at least some models of Cisco routers.  A firewall does more than just route (there are also firewalls that do not route).  They examine the various characteristics of the packets, be they layer 2, 3, or 4 and make decisions based on those characteristics.  As for IPv6, many devices have random number based addresses that cannot be (easily) disabled.  In this case, filtering on IP address is not an option, but filtering on MAC should be.



  • After reading a few threads on firewall rules based on MAC addresses, I figure I would post my use case here on why I would want such a feature.

    I have a virtual lab on one of my machines that I am creating and destroying Vms all the time. While I want a set of Vms to have access to my local physical network services such as NAS, I want silently block those VM's from autoupdating from the Inter-webs. I do use snapshots and restore liberally but I would have to fastidiously monitor for any change to the OS or other apps to be sure my
    tests are not tainted.

    Insuring my VMs use a range of MAC addresses and firewalling them at the LAN allows me to consume internal services and watch for
    DNS resolves or direct IP attempts for updates on those VMs.

    Thoughts ?

    • Joe


  • My use case: denying IPv6 entirely to certain Android devices (post).
    Currently using a separate WAP+interface to create an IPv4-only subnet.



  • @heper:

    …so a lot of work & limited use case for the majority of the users...

    I know this is a relatively old thread, but I think this comment misses the point entirely.

    MAC address filtering is only of limited use case for the majority of users today, because the majority of users are still using IPv4 and MAC based filtering gives them nothing they need..

    As users transition to IPv6, it will become the major use-case. Because, for practical purposes, with IPv6 a rules-based system that uses IP addresses does not work.

    This means pfSense will increasingly become ineffective as a network security device and people will stop using it. I'm sure none of us want that!

    Cheers,

    Keith



  • Continuing the discussion on implementation challenges…

    If pf does not support MAC based filtering then this, indeed, does present issues. However, I will point out that MAC based filtering, at the low-level, isn't necessarily required.

    What is required, to support IPv6, is "MAC-specified" filtering. That is to say, the ability to specify the device or devices to be filtered by MAC address. This could then be dynamically translated into an equivalent IPv6 (e.g. using information from the NDP) before being pushed into pf. This would obviously require regular updates (perhaps driven from NDP updates). It would be roughly analogous to specifying hosts by URL or DNS name.

    Of course, this would not be trivial, but it sounds a lot less problematic than trying to mix ipfw and pf rules.

    Cheers,

    Keith



  • I was quite surprised when I learned that the BSD iptables equivalent, pf, does not support L2 filtering. Until now I assumed this was possible the same way it is with iptables. However, I agree that there are some situations in which L2 filtering is helpful even though regular firewalls are supposed to work on L3. I've used MAC filters in the past with other firewalls and it worked as expected.  In this thread it's the same as in others, people try to reason away the need for L2 filters on firewalls alltogether, but that does not solve the problem. People try to accomplish the same things with pfsense they have been doing with iptables for years, and that's completely legitimate.

    I suggest to consider L2 MAC filtering a feature request for future releases of pfSense. To keep things easy, I would not mix L3/L2 in the firewall roules but rather suggest to implement a separate chain for MAC filters independent of the pf rules.



  • Hello,

    I'm following up this thread.
    Did someone find a way to block a MAC address (without IP reservation that will be easy to bypass ) ?

    Thanks


  • Rebel Alliance Global Moderator

    "(without IP reservation that will be easy to bypass ) ?"

    So you think changing a mac address is difficult?  Takes .2 seconds to set a different mac address.



  • @johnpoz:

    "(without IP reservation that will be easy to bypass ) ?"

    So you think changing a mac address is difficult?  Takes .2 seconds to set a different mac address.

    In fact, it's easier than changing the IP address, as you don't need to access pfSense, just the computer.


  • Rebel Alliance Global Moderator

    if your really worried you could always enable static arp.. Now someone trying to change and IP to get around a block would not be able to talk to pfsense from that different IP.



  • @johnpoz:

    "(without IP reservation that will be easy to bypass ) ?"

    So you think changing a mac address is difficult?  Takes .2 seconds to set a different mac address.

    I'm just saying that this is more easy for a basic user (99.9% of my customers) to change his IP than change his MAC address.
    But I didn't want to debate on this because each situation and each need is different.

    Just wanted to know if someone finds a way to do that with pfSense.


  • Rebel Alliance Global Moderator

    99% of your users not going to know how to change even the IP ;)  And very high percentage that do would prob know how to change the mac address as well.

    If your concerned with such things going on, then use static arp to deal with it.



  • @Florent.a:

    @johnpoz:

    "(without IP reservation that will be easy to bypass ) ?"

    So you think changing a mac address is difficult?  Takes .2 seconds to set a different mac address.

    I'm just saying that this is more easy for a basic user (99.9% of my customers) to change his IP than change his MAC address.
    But I didn't want to debate on this because each situation and each need is different.

    Unless they work in an IT environment, I suspect most people wouldn't even know the difference between an IP and MAC address, let alone how to change them.  I agree with johnpoz on this, map IP addresses to MACs in the DHCP server and use static ARP.



  • Sir,
    If you have these problems, have you considered os10/onie environment? (Brtables?)
    I have zero experience with oboe things but this would seem wise.
    Sincerely,
    magrw2066



  • if your really worried you could always enable static arp.. Now someone trying to change and IP to get around a block would not be able to talk to pfsense from that different IP.

    How many get their IPv6 address via ARP?  Not many. ;)

    The world is moving to IPv6 and most devices will be using privacy addresses that change every day.  Filtering outgoing traffic only on IPv6 address will not work.  Bottom line, pfSense & pf will have to be updated to the 21st century, if it's to be able to filter outgoing traffic.  As I mentioned before, people have to get out of the IPv4 mindset, as many things are different in IPv6.  Also, crippling network functionality is not the solution to this problem, as others in this thread seem to think.



  • Umm my response seems lost.
    Try ONIE boxes(not OBIE) and/or brtables command.
    Sincerely,
    Magrw2066



  • Just want to say. You guys might want to change this wikipedia page:
    https://en.wikipedia.org/wiki/Comparison_of_firewalls
    Since it states that pfsense has rules for blocking by mac address. It deceives people (like me) to think that pfsense can block by mac address.



  • This is one feature that should definitely be added. IPtables has it, IIRC. With IPv6 privacy addresses changing daily, it's not possible to have an IPv6 address rule that would last longer than a day.