MikroTik Guide
An isometric three-antenna router sits on a dark circuit-board platform with glowing pink cables branching to multiple connected network nodes.
configuration

RouterOS DHCP Server Setup for VLANs

Set up MikroTik DHCP on two RouterOS VLANs. Check bridge tags and access-port PVIDs, configure each pool and gateway, and verify both client leases.

By MikroTik Guide Editorial · · 6 min read

On MikroTik RouterOS, bind one DHCPv4 server to each VLAN interface on the bridge. Give that interface its subnet’s gateway address, attach an address pool, and set the gateway and DNS in the matching DHCP network entry. VLAN 10 and VLAN 20 then hand out settings from their own subnets.

This example starts with a working VLAN-filtered bridge. If you still need to set up the bridge, use the RouterOS VLAN filtering guide first. Enabling VLAN filtering before management access is configured can lock you out.

The three objects and how they find each other

  • IP pool (/ip/pool). Set ranges to the addresses DHCP can assign. Keep the gateway address outside the range.
  • DHCP network (/ip/dhcp-server/network). Set address to the subnet the leased addresses belong to. This entry supplies the subnet mask, gateway and dns-server values to clients.
  • DHCP server (/ip/dhcp-server). Set interface to the VLAN interface and address-pool to the pool name. The subnet of the leased address determines which DHCP network settings apply.
VLANSubnetDHCP pool rangeGatewayDNS in this example
10 (LAN)192.168.10.0/24192.168.10.100–192.168.10.199192.168.10.1192.168.10.1
20 (IoT)192.168.20.0/24192.168.20.100–192.168.20.199192.168.20.1192.168.20.1

The DHCP setup wizard calls the pool range addresses to give out. For a manual setup, enter the same range as ranges= when creating the pool. MikroTik DHCP documentation

VLAN plan: one server per VLAN interface

Check the client path through the bridge

In this example, ether2 is the trunk to a downstream switch and carries VLANs 10 and 20 tagged. A client can connect through a switch access port on either VLAN or directly to the corresponding router access port. MikroTik Bridge VLAN Table documentation

Direct access, VLAN 10
Client --untagged--> ether3 (PVID 10) --VLAN 10--> bridge1 --> vlan10-lan --> dhcp-lan

Via the trunk, VLAN 20
Client --untagged--> switch access port (PVID 20)
       --tagged VLAN 20 from switch trunk--> ether2 --> bridge1 --> vlan20-iot --> dhcp-iot

On ingress, the access port’s PVID assigns a VLAN to the client’s untagged traffic. On the trunk, the switch has already tagged the frame. Tagging bridge1 in both rows lets the router’s VLAN interfaces receive their traffic. Replies leave access ports untagged and the trunk tagged.

/interface/bridge/port/print
/interface/bridge/vlan/print

With the example links active, check the access-port PVIDs and these two bridge1 VLAN rows. Keep a separate row for each access VLAN. On the downstream switch, check that the router-facing trunk carries both tags and its client access ports use the matching PVIDs. MikroTik Bridging and Switching manual

VLAN IDCurrent taggedCurrent untaggedRouter access-port PVID
10bridge1, ether2ether310
20bridge1, ether2ether420

Create the VLAN interfaces and DHCP servers

Use these blocks for new DHCP scopes. If a VLAN interface or scope already exists, check its settings against the example and update the existing entries. For each VLAN, create the interface, add its gateway address, create the pool and network entry, then enable the server on that VLAN interface. MikroTik DHCP Server manual

The example advertises the router as DNS. Check allow-remote-requests with /ip/dns/print. If it is off, confirm that the firewall permits DNS from the intended VLANs and blocks it from the WAN before running /ip/dns/set allow-remote-requests=yes. You can also set dns-server to another resolver those clients can reach. MikroTik DNS manual

VLAN 10

/interface/vlan/add name=vlan10-lan interface=bridge1 vlan-id=10
/ip/address/add address=192.168.10.1/24 interface=vlan10-lan
/ip/pool/add name=pool-lan ranges=192.168.10.100-192.168.10.199
/ip/dhcp-server/network/add address=192.168.10.0/24 gateway=192.168.10.1 dns-server=192.168.10.1
/ip/dhcp-server/add name=dhcp-lan interface=vlan10-lan address-pool=pool-lan disabled=no

VLAN 20

/interface/vlan/add name=vlan20-iot interface=bridge1 vlan-id=20
/ip/address/add address=192.168.20.1/24 interface=vlan20-iot
/ip/pool/add name=pool-iot ranges=192.168.20.100-192.168.20.199
/ip/dhcp-server/network/add address=192.168.20.0/24 gateway=192.168.20.1 dns-server=192.168.20.1
/ip/dhcp-server/add name=dhcp-iot interface=vlan20-iot address-pool=pool-iot disabled=no

Use the RouterOS firewall rules guide to review services each VLAN can reach on the router and traffic between VLANs.

Things to test before you call it done

Connect a DHCP-enabled test client to each VLAN in turn. On Windows, use the commands below with your adapter name in place of Ethernet. Run them from the client’s console because releasing the address interrupts that adapter’s connection. Microsoft’s ipconfig reference

ipconfig /release Ethernet
ipconfig /renew Ethernet
ipconfig /all

On the router, check the interface addresses, server bindings, network entries and leases. RouterOS Console manual

/ip/address/print
/ip/dhcp-server/print
/ip/dhcp-server/network/print
/ip/dhcp-server/lease/print

For each client, match its IPv4 address and adapter MAC address to a bound row on the expected server. Check that a dynamic lease is inside its VLAN’s pool range. Compare the client’s subnet mask, default gateway and DNS with the configured network entry. The table shows one possible address per VLAN.

Client connectionExample client IPv4Expected gateway and DNSMatching RouterOS lease
VLAN 10, directly on ether3192.168.10.100/24192.168.10.1192.168.10.100, same client MAC, dhcp-lan, bound
VLAN 20, switch access port via ether2192.168.20.100/24192.168.20.1192.168.20.100, same client MAC, dhcp-iot, bound
SymptomWhat to check
Server is invalid (I)Check that the server’s INTERFACE is the intended VLAN interface, that the VLAN interface is on bridge1, and that the gateway address is assigned there. Check X separately for a disabled server.
Client has no leaseCheck the access-port PVID and the active tagged and untagged members in the bridge VLAN table. If using the trunk, check the tag at both ends. Confirm the server is enabled and compare /ip/pool/used/print with the range in /ip/pool/print. MikroTik IP Pools documentation
Client has a lease from the wrong subnetCheck the client’s reported DHCP server and look for its MAC in the RouterOS lease list. If it matches the other scope, check the port’s PVID and trunk VLAN mapping. If another device issued the lease, investigate that DHCP server.

Lease time and authoritative, read against the RFC

lease-time sets how long a client can use the assigned address. By default the client starts renewal with its issuing server halfway through the lease and tries rebinding by broadcast at 87.5% if renewal has failed. RFC 2131

With authoritative=yes, RouterOS can send a DHCPNAK for an address it cannot give, so a client carrying a stale lease starts over. With authoritative=no, the server ignores broadcast requests for those addresses. conflict-detection uses ARP and ICMP to check a dynamic address before offering it. MikroTik DHCP Server manual

Static leases, options and option 121

To reserve a device’s current address, find its bound entry with /ip/dhcp-server/lease/print. Run /ip/dhcp-server/lease/make-static with that lease’s row number from the same session. Setting rate-limit on a static lease creates a dynamic simple queue. MikroTik DHCP documentation

Define custom options in /ip/dhcp-server/option and use dhcp-option on the appropriate DHCP network entry. Option 121 sends classless routes to clients that support it. If those clients receive both option 121 and the Router option, they use option 121 for routes, so include the default route there too. RFC 3442

For option 121, 0x100A32C0A80A0200C0A80A01 encodes a route to 10.50.0.0/16 via 192.168.10.2 and a default route via 192.168.10.1. The first route uses 10 for the prefix length in hex, 0A32 for the destination bytes and C0A80A02 for the next hop. The default route starts with 00 and goes straight to its gateway bytes, C0A80A01. Use only routes and next hops that exist on your network. MikroTik DHCP Server manual

Rogue servers

To detect an unexpected DHCP server, add an entry under /ip/dhcp-server/alert. Set interface to the VLAN interface to monitor and put the approved DHCP server MAC addresses in valid-server. MikroTik DHCP documentation

Enable the alert after adding it and check /log/print where topics~"dhcp" for replies from unknown servers. Avoid running the alert on an interface where the router itself is a DHCP client, since the alert sends discovery requests. MikroTik DHCP Server manual

Evidence and limits. The examples follow MikroTik’s DHCP and Bridge VLAN Table documentation for RouterOS 7. The commands were not run on a router.

Sources

  1. DHCP - RouterOS Documentation
  2. Bridge VLAN Table - RouterOS Documentation
  3. IP Pools - RouterOS Documentation
  4. DHCP Server - RouterOS Manual
  5. Bridging and Switching - RouterOS Manual
  6. DNS - RouterOS Manual
  7. Console - RouterOS Manual
  8. ipconfig - Microsoft Learn
  9. RFC 2131: Dynamic Host Configuration Protocol
  10. RFC 3442: The Classless Static Route Option for DHCPv4

Related