I’m working on an automation testing setup using RouterOS and need some help with DHCP configuration. Here’s what I’m trying to achieve:
Network: 192.168.0.1/24
DHCP IP Pool: 192.168.0.2-192.168.0.254
Requirements:
DHCP Reserved IP for Ether1: 192.168.0.2
DHCP Reserved IP for Ether2: 192.168.0.3
From the older threads in this forum, I found that assigning each Ethernet port its own DHCP server with a subnet of /30 works for assigning a single IP to each Ethernet port, like this:
Ether1: 192.168.1.1/30
Ether2: 192.168.1.5/30
Ether9-16: 192.168.0.1/24 (Dynamic IPs)
This setup works, but I’ve encountered a problem. My PC, which is configured with a static IP of 192.168.0.2 and gateway 192.168.0.1, cannot ping the 192.168.1.* addresses. When I trace the route, it seems the gateway 192.168.0.1/24 isn’t being used due to the route table metric on the PC. Probably because I have two routers connected to the PC (one for the subnetwork and another for internet access on a different NIC).
So, my question is: Is there a way to achieve DHCP reservation based on Ethernet port number in RouterOS, similar to using a client-id, but without needing to allocate MAC addresses? This would help avoid the issue with routing on the PC.
Thanks in advance for any help or suggestions!
Side note: I understand this might be an unusual request, but it’s necessary for my application. The devices I’m connecting can’t view the assigned IP addresses easily. Also, MAC binding isn’t an option since I don’t know the MAC addresses beforehand (they’re random).
There is not an easy way to allocate an address based on physical port rather than MAC or Client ID - whilst Mikrotik can include Option 82 for ports in a bridge the DHCP server has no mechanism to use the Agent Circuit ID.
For your setup with additional small subnets then adding static routes on the PC for both 192.168.1.0/30 and 192.168.1.4/30 (or just 192.168.1.0/29) via 192.168.0.1 should be sufficient.
I’ve read about DHCP Option 82 in Cisco manual while searching through the web for solution, but I’m still a bit unclear on how to implement it in my situation in Mikrotik. Is there a guide or example that could help me use DHCP Option 82 to achieve what I’m looking for?
As for the static route suggestion, I’ve encountered an issue where Windows tends to pick only one route from the routing table, which doesn’t seem to work well for my setup. So I’m hoping to find a more dynamic solution.
Any further guidance would be greatly appreciated!
As mentioned the Mikrotik DHCP server does not support matchind agent circuit ID information in DHCP requests so you would need to run a DHCP server elsewhere and configure that to return fixed addresses for the specific ethernet ports, or from a pool otherwise.
If there are multiple routes for the same destination subnet the lowest metric will be preferred, the metric values assigned by windows is not always obvious. For unique destination addresses however that route will always be used.