Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static leases assigns the same IPv6 to multiple NICs #175

Open
lslqtz opened this issue Aug 13, 2021 · 1 comment
Open

Static leases assigns the same IPv6 to multiple NICs #175

lslqtz opened this issue Aug 13, 2021 · 1 comment

Comments

@lslqtz
Copy link

lslqtz commented Aug 13, 2021

My computer has multiple NICs (Ethernet, Wi-Fi), these NICs share the same DUID, they will get the same IPv6 address, resulting in a conflict. IAID can distinguish different NICs, but IAID seem to be randomly assigned by the OS.
I tried not to specify a DUID, but it doesn't seem to work.
Edit: I am trying to update to the latest version of odhcpd and will supplement it again after confirmation
Jun 14, 2021 (564d25e) still happens

image

(same DUID and different IAID)

My /etc/config/dhcp file

config dnsmasq
	option localise_queries '1'
	option local '/lan/,/r.acgn.xyz/'
	option expandhosts '1'
	option leasefile '/tmp/dhcp.leases'
	option localservice '1'
	option authoritative '1'
	option rebind_protection '0'
	option nonwildcard '0'
	option cachesize '0'
	option domain 'lan'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	list server '127.0.0.1#5333'
	option noresolv '1'

config dhcp 'lan'
	option interface 'lan'
	option ra_slaac '0'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'
	option ignore '1'
	option dhcpv6 'server'
	option ra 'server'
	option ra_useleasetime '1'
	option ra_management '2'
	option ra_lifetime '600'
	option leasetime '10m'
	option preferred_lifetime '10m'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

config srvhost
	option srv '_vlmcs._tcp'
	option target 'asd'
	option port '1688'
	option class '0'
	option weight '100'

config host
	option name 'asdde-iMac'
	option mac '30:5a:3a:05:e6:15'
	option ip '192.168.233.2'
	option leasetime '10m'
	option hostid '2'

config domain
	option name 'r.acgn.xyz'
	option ip '192.168.233.233'
@lslqtz lslqtz changed the title Add optional IAID option for static leases Static leases assigns the same IPv6 to multiple NICs Aug 13, 2021
@mpeleshenko
Copy link

mpeleshenko commented Sep 16, 2022

I noticed the same behavior just now after recently getting IPv6 from my ISP and trying to assign different IPv6 addresses to 2 different interfaces on the same Windows server.

Looking through the code, I came across the below which looks for a static lease in the config trying to match first on DUID, and falling back to MAC address.

odhcpd/src/dhcpv6-ia.c

Lines 1279 to 1281 in 860ca90

l = config_find_lease_by_duid(clid_data, clid_len);
if (!l)
l = config_find_lease_by_mac(mac);

Now as far as I understand, IPv6 does not actually look at the Layer 2 MAC address of the incoming packet and odhcpd is actually parsing it out of the DUID, which is defined to have the MAC address if it's a Type 1 or Type 3 DUID (See here for details on the different DUID types).

odhcpd/src/dhcpv6-ia.c

Lines 1252 to 1259 in 860ca90

if (otype == DHCPV6_OPT_CLIENTID) {
clid_data = odata;
clid_len = olen;
if (olen == 14 && odata[0] == 0 && odata[1] == 1)
memcpy(mac, &odata[8], sizeof(mac));
else if (olen == 10 && odata[0] == 0 && odata[1] == 3)
memcpy(mac, &odata[4], sizeof(mac));

Given the DUID, or even embedded MAC address, are the same between both interfaces, odhcpd picks up the same static lease from the config to give to both interfaces, resulting in a conflict.

I think it would make sense to add an IAID option for static leases and have odhcpd match on that as well when looking for a static lease in the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants