DHCP pool shared across multiple VLANs

I’m looking to migrate several VLANs from a Cisco layer 3 switch to Mikrotik. I’d like to have several VLANs share a single DHCP pool - on my current Cisco setup, I’m able to do this by creating a loopback interface that acts as a gateway for a large subnet, and each VLAN interface has ip unnumbered to the loopback interface. This allows me to keep VLANs separate, but also not have to worry about tons of DHCP pools filling up. It works quite well for my setup, but I need to add some authentication features available in RouterOS.

Separate pools for each VLAN results in too many wasted IPs, and it’s more of an administration hassle than I prefer to deal with. Is there any way to do something similar with RouterOS?

Could you just make a new DHCP-Server for each VLAN and use the same pool?

That’s what I’ve been trying to set up, but so far haven’t been able to get the configuration right. Seems that hosts on only one interface at a time can reach any given destination IP. Relevant config portions look like this:

/ip address
add address=x.x.x.33/27 interface=vlan1234 network=x.x.x.32
add address=x.x.x.33/27 interface=vlan1235 network=x.x.x.32

/ip pool
add name=dhcp_pool ranges=x.x.x.34-x.x.x.62

/ip dhcp-server
add address-pool=dhcp_pool disabled=no interface=vlan1234 lease-time=2m name=dhcp-1234
add address-pool=dhcp_pool disabled=no interface=vlan1235 lease-time=2m name=dhcp-1235

/ip dhcp-server network
add address=x.x.x..32/27 dns-server=1.1.1.1,1.1.1.2 gateway=x.x.x.33

Ok, seems to be working as long as I add a static route for each DHCP client IP /32 through the proper VLAN interface. Seems that the Cisco does this automatically. Any thoughts as to how to handle this in RouterOS?

What happens if you add a route to the /27 on all vlan interfaces and enable the ‘add arp for leases’ option on the dhcp server?

You could try putting a single DHCP server on a bridge interface on the MT with the VLAN’s connected to that same bridge (just like on your Cisco).

Out of curiosity, what is the use case for multiple VLAN’s all bridged together using the same subnet?

Rich

do not forget that it is possible to send additional options to clients, for example, additional routes, if all of sudden configuration you have set up for DHCP-server is not working and additional configuration is required on the client side.

You can’t have addresses from the same network on two different interfaces.
To make it work either bridge both interfaces and run one DHCP server ob bridge, or split /27 network in two subnets.

Take a look at the Layer2-Switching Capabilities of your Mikrotik Device, maybe this is enough your your needs.

It looks like there’s a dchp server lease-script and maybe a binding-script (is this v6 only?) If you could pass the interface name to it, it could possibly add or remove the static route upon lease assign/deassign.