How can I prevent IP assignment using a MAC address in DHCP?

Hello!

First of all, I would like to congratulate the developers of this project for their great work and all the users of this forum.

I installed Nethsecurity a few days ago and so far I have been able to configure everything without any problems using the documentation, but today I encountered a problem.Let me describe my situation:

I have installed nethsecurity at a technical school, where students work both on the school’s computers and on their own laptops. The school’s computers have fixed IP addresses and are on a domain, but the laptops are assigned a dynamic DHCP address to connect. The problem is that the students, abusing our trust, also connect their other devices, especially their cell phones, which saturates the network and the 80 IP addresses that the DHCP server can assign, so that sometimes people who use laptops are left out.

We could register the MAC addresses of the laptops and only allow those, but it would be very messy. Plus, if the students change their laptop or tablet, they would be locked out.

My idea is that everyone can connect except for certain MACs to which the DHCP server would not assign an IP address, but honestly, I haven’t found that option in Nethsecurity.

Is it possible to configure this? Can any of you help me?

Greetings!

3 Likes

I’m not sure if that can work. How do you want to forbid MAC addresses that you don’t know?

I’d go with the MAC binding, see DNS & DHCP — NethSecurity documentation

When a student has a new laptop he needs to tell you and you can change his DHCP reservation to the new MAC.

:heart:

Basically, I’m looking for an option that my ISP’s router had that allowed me to block the MAC address of a specific device so that it wouldn’t be assigned an IP address.

It would be great if in Dynamic Leases, when you click on the three dots, in addition to “Add reservation”, something like “Block MAC in DHCP” would appear.

2 Likes

BTW, welcome to NethServer community!

I think this is nice feature request so I added the tag to the title.

Dnsmasq is used in NethSecurity so basically it should be possible to configure it via the config file on CLI using something like

dhcp-host=11:22:33:44:55:66,ignore

I’m going to check and report…

2 Likes

Thanks a lot! I will try to block MACs on cli, and wait for that option on UI

1 Like

I found another way to block DHCP conections using MAC on UI.
If you go to Static Leases and create a new reservation (“Add Reservation“), and you assign to the MAC a out of range IP, it seems to work (is not assigned to any interface). For example, if my LAN network is 192.168.1.x and I assign an IP address of, say, 192.168.10.x, those users will not be able to access the internet using that IP address.
I suppose it’s not the most correct way to do it, but I guess it will work.

Cheers!

2 Likes

Good idea! Thanks for sharing.

EDIT:

I think it’s a good solution for now. I tried to change it using uci and it worked to set it to ignore instead of an IP but it destroys the UI view so I guess it’s not that easy to implement.

I also found that Android devices use a random MAC, don’t know about IPhones…

1 Like

Hi,

This is true for androids, but on the settings panel, there’s a button ‘to not use a random MAC’.

When creating reservations, the user is forced to use the real mac, so the Network Admin can control who can access what!

Best regards,

Hi @leillo1975 this is true a nice way to block, and it also brings another missing feature that NethSec needs:

  • When using pfsense or opnsense, there’s a way to set DNS for each device.

What this feature does is allows you set the IP of a particular user to use the same network, allows it to use resources on the LAN (printers) and it gives it a separate DNS where you can block or allow only resolutions to certain domains.

Thanks,

Best regards,

Sorry, I can’t find that option on Nethsec. Can you tell me exactly where it is?

Hello!
The trick works fine I guess, however, for this feature I’d recommend switching the access points to dedicated VLANs.

This ensures the “external” devices have their own dedicated network and then you can allow specific access to some of the internal services IF you need it. Having an external device attached to a secure network, whether it’s a smartphone of a student or something else, is really not ideal due to security concerns, if a device doesn’t have an IP doesn’t mean it can’t hurt the network!

If you need anything else, feel free to ask!

2 Likes