OPNsense Forum

Archive => 22.1 Legacy Series => Topic started by: TheGreatBellend on February 19, 2022, 10:08:48 PM

Title: DHCP not working for VLANS
Post by: TheGreatBellend on February 19, 2022, 10:08:48 PM
So I watched ton's of youtube videos, everyone from random indian blokes to Lawerence Systems, and for the life of me I cannot get this working.

So here is my network config

LAN 1, 192.168.1.1/24
Servers 2, 192.168.2.1/24
Home Wifi 10, 192.168.10.1/24
IotWifi 20, 192.168.20.1/24
WifeWifi (no security per wife request) 30, 192.168.30.1/24
Guest Wifi 40, 192.168.40.1/24

I have 4 Unifi AP's and have a Unifi controller built on docker(running on Unraid on a host setup, so it has its own IP address), The Unifi config is correct with all wifi network connections being routed to their specific VLANs.

I set up firewall rules(for setup purposes) for all/any for inter-VLAN communication.

I configured interfaces and DHCP for each VLAN with static and their IP addresses above.

If I remove the VLAN's, they can get 192.168.1.x IP's but it seems as though the DHCP absolutely refuses to work on any of the VLAN's, I even made new gateway's on each VLAN to see if that would fix it, it did not. All I get is 169 IP's from the devices attempting to use a VLAN, which means it cant talk to the DHCP server.

Any advice would be greatly appreciated as I am trying to get rid of my Unifi UDM due to their utterly terrible Suricata implementation.
Title: Re: DHCP not working for VLANS
Post by: cookiemonster on February 19, 2022, 10:23:00 PM
Taking the unifi AP controllers out of the equation i.e. assuming they don't attempt to give out dhcp addresses, the in OPN, on Services > DHCPv4 > {VLAN name} > At the top select "Enable DHCP server on the {VLAN name} interface". This is for ipv4 of course, and chose your options.
Then you need to have firewall rules to allow dhcp (udp 67 and 68). Creating the VLAN, I think with OPN default options it creates them automagically. Check they're there. If not, you can copy it from the LAN.
Title: Re: DHCP not working for VLANS
Post by: Bonkerton on February 20, 2022, 02:38:28 AM
Have you tried rebooting after setting up the new VLANs ?

Recently had the case where I added a new VLAN.
Everything seemed (and turns out was) set up fine, but I couldn't get DHCP to work. Spent a few hours eliminating everything else and finally decided to reboot.

Et voila, everything worked as expected after the reboot.
Title: Re: DHCP not working for VLANS
Post by: TheGreatBellend on February 20, 2022, 04:59:25 AM
Quote from: cookiemonster on February 19, 2022, 10:23:00 PM
Taking the unifi AP controllers out of the equation i.e. assuming they don't attempt to give out dhcp addresses, the in OPN, on Services > DHCPv4 > {VLAN name} > At the top select "Enable DHCP server on the {VLAN name} interface". This is for ipv4 of course, and chose your options.
Then you need to have firewall rules to allow dhcp (udp 67 and 68). Creating the VLAN, I think with OPN default options it creates them automagically. Check they're there. If not, you can copy it from the LAN.


This fixed it.

The rules were not created automagically. I rebuilt all of them and then they did show up. That's an interesting bug.

Thank you for the help!

Quote from: Bonkerton on February 20, 2022, 02:38:28 AM
Have you tried rebooting after setting up the new VLANs ?

Recently had the case where I added a new VLAN.
Everything seemed (and turns out was) set up fine, but I couldn't get DHCP to work. Spent a few hours eliminating everything else and finally decided to reboot.

Et voila, everything worked as expected after the reboot.

I work in IT hahaha, the first thing i tried was a reboot. Sadly as stated above I believe it was a bug. Not sure how to replicate it, or I would report it =(