16 DHCP servers on a CRS125-24G

Hello All,
I have a … strange request that i hope someone can help me with.
I would like to be able to plug a device into port 1 and have a dhcp server serve up 1 specific ip address to what ever device plugs into it.
This would basically be a DHCP server with a pool of 1 ip address.
BUT, i would like to do this to the first 16 ports on the switch, each port with a different ip address.
e.g.
port 1 will server up 192.168.101.1
port 2 will server up 192.168.101.2
port 3 will server up 192.168.101.3
port 16 will server up 192.168.101.16

The intention is that i can plug a device into a port and know exactly what ip address it will be given (without having to manually set any static ip addresses in the device or mac addresses in the server)

I have tried several different configurations…but all of them end up with the dhcp server indicating RED in winbox.

Does anyone know if this can be achieved with this device?
This setup is being used in a test environment where I have 800 devices to plug into 40 CRS125 switches (so manually changing ip addresses can be a several day exercise)

Thanks for your help
Regards
Stuart

Run one dhcp server with one pool, then set the leases as static. i.e set the master port of each interface to e.g ether1, and run the dhcp server on there.

thanks for your reply.
If i set the leases to static, wont the ip addresses be tied to the mac address of the device i am plugging in?

Correct, but they can be plugged into e.g ether 2 or ether 16 and they will still get the same IP.

Ah, ok. thats a bit different to what i need.
I need to be able to plug a device in to port 1 and get ipaddress 192.168.101.1
BUT if i unplug that device and plug it into port 16, i want the device to get 192.168.101.16
Is this possible?
Thanks
Regards
Stuart

You have to do some gymnastics with proxy-arp and properly set up a network and pool for each interface.
I assumed a configuration where there may exist other interfaces that would occupy the remainder of the 192.168.101.X range, and that .254 is the default GW (i.e. the Mikrotik’s IP in that range)

I achieved your desired behavior using a CHR (virtual ROS) in GNS3 with physical interface ether1 and ether2 behaving in your desired manner. I made a bridge “lan” which acts as normal dhcp where clients get whatever IP is available from a pool, and with a normal long-lived lease. I connected ether3 to this bridge as the example, but obviously you could put more ports on the bridge, or if you didn’t want a bridge you could just move the configurations of LAN onto ether3 instead and use an external switch - whatever…

Here’s the configuration to make it happen:

/interface bridge
add arp=proxy-arp name=lan
/interface ethernet
set [ find default-name=ether1 ] arp=proxy-arp
set [ find default-name=ether2 ] arp=proxy-arp
/interface bridge port
add bridge=lan interface=ether3
/ip pool
add name=ether1 ranges=192.168.101.1
add name=ether2 ranges=192.168.101.2
add name=lan ranges=192.168.101.100-192.168.101.253
/ip dhcp-server
add address-pool=ether1 authoritative=yes disabled=no interface=ether1 name=server1
add address-pool=ether2 authoritative=yes disabled=no interface=ether2 name=server2
add address-pool=lan authoritative=yes disabled=no interface=lan name=dhcp-lan
/ip address
add address=192.168.101.254/32 network=192.168.101.1 interface=ether1
add address=192.168.101.254/32 network=192.168.101.2 interface=ether2
add address=192.168.101.254/24 network=192.168.101.0 interface=lan
/ip dhcp-server network
add address=192.168.101.0/24 gateway=192.168.101.254
add address=192.168.101.1/32 gateway=192.168.101.254 netmask=24
add address=192.168.101.2/32 gateway=192.168.101.254 netmask=24

NOTE the IP addresses aren’t done in the usual way for ether1 and ether2 - the router has the SAME IP for ether1, ether2, and LAN - except the mask for ether1 and ether2 is /32. It’s the “Network” field that sets what the remote address is for each interface - in the case of LAN, it’s just the normal, actual network address of 192.168.101.0 (where the ACTUAL /24 is connected)

I recommend a very short lease duration for the per-interface dhcp servers, because if you disconnect one device and connect another, the pool remains unavailable until the lease expires for the previous device. (i.e. the lease doesn’t clear up just because the interface goes down when you unplug something from it)

The way this solution works is that it creates an isolated /32 network for each physical interface, and uses proxy arp to glue them together as a single /24. The netmask=24 is necessary for these special networks so that clients are told they’re on a /24 network and thus they’ll send ARP requests to communicate with other hosts in 192.168.101.X - and proxy-arp will pick this up and cause the hosts to forward everything to the router.

It’s a hack - it’s ugly, but it works. I don’t recommend this for a production environment. If you’re trying to track customers or something, you should use RADIUS or some other form of logging who is assigned which IP addresses.

Hello ZeroByte,
Thanks for that, it works perfectly. I have modified it for 16 ports and does what i need.
Now i need to read up on proxy arp to understand what it is actually doing :slight_smile:
Thanks again.
Regards
Stuart

When configured for proxy arp, an interface will respond to any arp request on behalf of all IP addresses which exist in the host’s routing table, and whose next hop is via any target which is not on the same interface where the arp was received.

In other words, if ARP for x.x.x.x comes in ether1 and the best route for that (including the default GW) points to any other interface, even a black hole route, then ether1 will reply to the ARP. The host which sent the ARP will now have the MAC of ether1 in its ARP cache. (Not the real MAC of the target IP - which may not even be known to the router, or it could be 12 hops away)