Community discussions

MikroTik App
 
MoMoMoMo
just joined
Topic Author
Posts: 8
Joined: Fri Sep 10, 2021 3:01 am

Static IP address on every port with lease on demand

Fri Sep 10, 2021 3:12 am

Hi everyone!

Every day I connect to my LAN about 50 devices just so I can connect to them, configure and disconnect. I do that using TP-LINK TL-ER6020. Even with DHCP lease time set to minimum, most of the time I have to search for currently connected device's IP.

Can I set up MikroTik (RB951Ui-2HnD) so every port has static IP with no lease time? I want to be able to connect to all devices under let's say 10.10.20.100 every time i plug something to specific eth port without waiting, even if it's 10 devices in 5 minutes.

Network I have in mind will be without WAN (just for config purposes). Is it doable?
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: Static IP address on every port with lease on demand  [SOLVED]

Fri Sep 10, 2021 11:36 am

It is not possible to do it without lease time because lease time is part of DHCP protocol. But you can get to the point where device plugged to particular port will have predictable IP address.

With some cludge:

  • remove all ether ports from bridge
  • configure IP addresses directly on ether interfaces, use long network masks (e.g. /30 or /29)
  • configure separate DHCP pool containing single IP address for each of those subnets
  • add DHCP servers one to each ether port. Configure some insanely short lease time (such as few minutes, some DHCP clients don't like very short lease times)
  • configure appropriate routing on your workstation to use RB as gateway towards those devices.
  • optionally configure src-nat on device etehr ports if devices don't like connections from "alien" networks

You'll probably still have to wait for DHCP leases to expire before plugging next device to same port (DHCP server probably won't send out lease with IP address whose lease did not expire yet). If you can't do it, you can make per-port subnets slightly larger (e.g. /29) which will allow for a few client IP addresses (/29 subnet allows 5 client addresses plus router's own) and you will have to try only a few (consecutive) addresses to find the one being used by currently connected device.
 
ConnyMercier
Forum Veteran
Forum Veteran
Posts: 723
Joined: Tue Dec 17, 2019 1:08 pm

Re: Static IP address on every port with lease on demand

Fri Sep 10, 2021 12:18 pm

I don't think there is an elegant way to solve this problem....
I Think @mkx has a good solution.


To add to his Solution:
I would try to create dhcp-pools with only 1 address
and add a Script / Scheduler to delete the Lease
For Exemple :
:if (![interface ethernet get ether2 running]) do={
foreach i in=[/ip dhcp-server lease find server=dhcp2] do={/ip dhcp-server lease remove $i}} else={
};
 
MoMoMoMo
just joined
Topic Author
Posts: 8
Joined: Fri Sep 10, 2021 3:01 am

Re: Static IP address on every port with lease on demand

Sat Sep 11, 2021 11:18 am

Thank you all for your responses!

Searching for IP is something I was hoping to avoid completely. I hope MikroTik will be smarter than TP-LINK with lease time. I have time set for 2 minutes and most of the time I am unable to retrive IP address even after 15 minutes form disconnecting device. Later today I will test Your ideas and come back with results. Thanks again!
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: Static IP address on every port with lease on demand

Sat Sep 11, 2021 3:41 pm

I hope MikroTik will be smarter than TP-LINK with lease time.

It's not entirely up to DHCP server (Mikrotik or TP-Link), it's up to DHCP client as well. RFC2131 defines granularity of 1 second for lease time and minimum lease time restriction was removed. DHCP clients might adhere to older RFC1541, which defined minimum lease time of 1 hour (granularity was 1 second as well). Standards allow clients to reject lease if they don't support some setting, such as lease times shorter than 1 hour. Since this is an already old standard revision, most DHCP clients support shorter lease times, but might still limit lease times to some (sane) minimum value ... thus either rejecting leases received from servers, or ignoring short lease time making even bigger problems (server might expire lease while client is still hanging on to it ... which might cause problems when clients decide to renew lease).

I'm looking forward to see your findings and progress.
 
MoMoMoMo
just joined
Topic Author
Posts: 8
Joined: Fri Sep 10, 2021 3:01 am

Re: Static IP address on every port with lease on demand

Sat Oct 23, 2021 6:00 am

So, I ended up with config suggested by @mkx. Works fine and short lease time is realy short and ports always are free after few minutes, so I'm happy.
Thank You all :)

Who is online

Users browsing this forum: No registered users and 80 guests