If you desire to know how to set up Mikrotik VLAN with multiple dhcp servers configured for the VLANs, this post is for you. After reading this post, you should be able to configure VLANs on a Mikrotik router and configure dhcp servers for all your vlans.
I have had some of my readers reached out to me, requesting that I make a post on implementing multiple dhcp servers. Although I have earlier written a post on how to set up vlans on Mikrotik routers, this post will include both vlan and dhcp configuration.
The first step is to creat a bridge and add the trunk interface to the bridge. The trunk port is the port connecting to your managed switch. The commands are given below
int bridge add name=trunk
int bridge port add bridge=trunk interface=ether1
int vlan add name=sales vlan-id=10 interface=trunk
int vlan add name=HR vlan-id=20 interface=trunk
Assign IP addresses to Vlan interfaces.
IP address add address=192.168.10.1/24 interface=sales
IP address add address=192.168.20.1/24 interface=HR
This is where we will configure two dhcp servers for the two vlans created in the steps above. We are only going to configure two dhcp servers here because we created two vlans. See commands in the steps below.
ip dhcp-server> setup
Select interface to run DHCP server on
dhcp server interface: sales
Select network for DHCP addresses
dhcp address space: 192.168.10.0/24
Select gateway for given network
gateway for dhcp network: 192.168.10.1
Select pool of ip addresses given out by DHCP server
addresses to give out: 192.168.10.2-192.168.10.254
Select DNS servers
dns servers: 192.168.10.1
Select lease time
lease time: 3d
Repeat steps for Vlan20 (HR)
We can verify this configuration with the ip dhcp-server print command
At this point, all that is left is the configuration of your managed switch. There, you will create vlans and assign access ports to vlans. The port connecting the the Mikrotik router must be configured as a trunk port for traffic across all vlans.
Note that there are many ways to implement vlan on Mikrotik and the method discussed in this tutorial is known as router on a stick.