tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
301 stars 50 forks source link

[Bug] Static DHCP leases with two DHCP servers #220

Closed nashaden closed 2 years ago

nashaden commented 2 years ago

Describe the issue

I have two DHCP servers running: one for my family and one for IOT devices. My notebook can connect to either of those networks (home or IOT) and thus get IP from either DHCP servers (10.12.12.0/24 or 192.168.12.0/24). I have it set as static DHCP with different comments (either 'Home: UBUNTU01' or 'IOT: UBUNTU01') for both DHCP servers. Instead of having two device trackers, I only have one (device_tracker.iot_ubuntu01) which says the device is home when connected to either of the networks and claims the IP is 192.168.12.9 even when it's connected to 10.12.12.0/24 network.

To be more visual:

  1. Notebook connected to 'home network' getting a static DHCP IP of 10.12.12.9 commented in Mikrotik as 'Home: UBUNTU01'
  2. Notebook connected to 'iot network' getting a static DHCP IP of 192.168.12.9 commented in Mikrotik as 'IOT: UBUNTU01'

In both the above cases there is only one device tracker: device_tracker.iot_ubuntu01 In both those cases device_tracker.iot_ubuntu01 says my notebook is at home with IP 192.168.12.9

Is it, maybe, because the same MAC address is twice on the leases list?

Software versions

config_entry-mikrotik_router-9671e9575ebb1b4ed691b32c3c53bb37.json.txt

tomaae commented 2 years ago

yes, tracking devices are unique by mac address. it wont care which network, its same device. this is by design.

are you saying that sensor shows that it is connected to wrong network and reports "home" status? that should not be technically possible. can you show me screenshots?

nashaden commented 2 years ago

Hi,

4 screenshots attached:

mikrotik > my laptop is static bound to IP from dhc1 screen_dhcp1

mikrotik > it's waiting for my laptop at dhcp2 screen_dhcp2

home assistant > shows i'm connected to dhcp1 screen_homeassistant_1

home assistant > no such entity as my laptop at dhcp1 screen_homeassistant_2

Even when I connect my laptop at dhcp1 and restart Home Assistant, still shows the same.

tomaae commented 2 years ago

Laptop one is not there because it is unique by mac address and you have name it differently under each network. There can be only one name displayed after all. You can just rename it to what you want in HA.

I see you are using capsman with this device connection. are you able to test the same behavior using cable? capsman and wifi implementation is bit different and I dont have a good way to test those in detail myself.

nashaden commented 2 years ago

Sorry for not replying for so long but I was away camping :-) Anyway, I've commented both entries for my laptop differently as each of those comments correpspond to a different DHCP server. What's strange is that although 'Tymek Laptop' entry is first on the list and the 'IOT: Ubuntu01' is somewhere at the bottom of the DHCP leases list still I always see only the latter one as home/away. I'll try the cable connection on the morrow and let you know.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity.