[1681886 views]

[]

Odi's astoundingly incomplete notes

New entries | Code

Making ntp-client (ntpdate) work in Gentoo

tl;dr:
/etc/dhcpcd.conf:
waitip 4
dhcpcd will background already after configuring an IPv6 address on the interface. Which may be seconds before you get an IPv4 lease and DNS information from the DHCP server. The ntp-client init script may therefore run before we have a valid /etc/resolv.conf and will fail due to name resolution not working.
Tell dhcpcd to background only after we haven an IPv4 address, which is like the whole point of DHCP these days. I don't consider the network "up" with IPv6 only.

It's particularly a problem when you get IPv6 router advertisements. Like in qemu VMs with user networking.

Look at the following log, where you see it backgrounding 3 seconds before the lease:
Oct  4 14:35:25 localhost dhcpcd[3356]: eth0: adding address fe80::59c1:f175:aeb3:433
Oct  4 14:35:25 localhost dhcpcd[3356]: DUID 00:01:00:01:1a:7a:85:31:52:54:00:12:34:56
Oct  4 14:35:25 localhost dhcpcd[3356]: eth0: IAID 00:12:34:56
Oct  4 14:35:25 localhost dhcpcd[3356]: eth0: rebinding lease of 10.0.2.15
Oct  4 14:35:25 localhost dhcpcd[3356]: eth0: probing address 10.0.2.15/24
Oct  4 14:35:26 localhost dhcpcd[3356]: eth0: soliciting an IPv6 router
Oct  4 14:35:26 localhost dhcpcd[3356]: eth0: Router Advertisement from fe80::2
Oct  4 14:35:26 localhost dhcpcd[3356]: eth0: adding address fec0::4f23:8633:1bba:42f5/64
Oct  4 14:35:26 localhost dhcpcd[3356]: eth0: adding route to fec0::/64
Oct  4 14:35:26 localhost dhcpcd[3356]: eth0: adding default route via fe80::2
Oct  4 14:35:28 localhost dhcpcd[3356]: forked to background, child pid 3384
Oct  4 14:35:31 localhost dhcpcd[3384]: eth0: leased 10.0.2.15 for 86400 seconds
Oct  4 14:35:31 localhost dhcpcd[3384]: eth0: adding route to 10.0.2.0/24
Oct  4 14:35:31 localhost dhcpcd[3384]: eth0: adding default route via 10.0.2.2


posted on 2016-10-04 13:15 UTC in Code | 0 comments | permalink