Modify

Opened 5 years ago

Last modified 18 months ago

#12167 accepted defect

sysntp not working with dual stack NTP servers if not IPv6-only connected

Reported by: Lutz.Pressler@… Owned by: jow
Priority: normal Milestone: Barrier Breaker 14.07
Component: base system Version: Attitude Adjustment 12.09 Beta
Keywords: ntp ipv6 Cc:

Description

IPv6 but no IPv4 connectivity.

host 2.openwrt.pool.ntp.org
2.openwrt.pool.ntp.org has address 204.235.61.9
2.openwrt.pool.ntp.org has address 173.244.211.10
2.openwrt.pool.ntp.org has address 198.110.48.12
2.openwrt.pool.ntp.org has address 216.144.229.211
2.openwrt.pool.ntp.org has IPv6 address 2a01:4f8:110:4443::1fef
2.openwrt.pool.ntp.org has IPv6 address 2001:4dd0:fb66::a
2.openwrt.pool.ntp.org has IPv6 address 2001:780:107:8::1
2.openwrt.pool.ntp.org has IPv6 address 2a01:238:43c2:fd00::123

root@OpenWrt:~# /usr/sbin/ntpd -dn -p 2.openwrt.pool.ntp.org
ntpd: resolved peer 2.openwrt.pool.ntp.org to 204.235.61.9
ntpd: send failed: Network is unreachable
ntpd: send failed: Network is unreachable
ntpd: send failed: Network is unreachable
ntpd: send failed: Network is unreachable
... nothing more seems to happen.

Why is ntpd preferring IPv4 and is it using more than one address per name at all? Host names with AAAA record(s?) only or literal IPv6 addresses do work.

Attachments (1)

0001-busybox-make-ntpd-prefer-IPv6-addresses.patch (3.3 KB) - added by mwarning 3 years ago.
Let ntpd prefer IPv6 over IPv4

Download all attachments as: .zip

Change History (12)

comment:1 Changed 5 years ago by jow

  • Owner changed from developers to jow
  • Status changed from new to accepted

comment:2 Changed 5 years ago by jow

The sysntpd resolver uses the libbb "host2sockaddr" convenience function to resolve the address. This unfortunately prefers IPv4 (or rather just takes the first address from the DNS response).

I can certainly change it to prefer IPv6 but a truly generic solution (e.g. keep retrying to connect forever or keep trying all received IP addresses) is going to be difficult.

comment:3 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

comment:4 Changed 3 years ago by yanosz

Hello,

is there any progress? I got stumbled into this issue, too

Thx, yanosz

comment:5 Changed 3 years ago by mwarning

Hi, we just stumbled over this problem as well.
What would be the downside when preferring IPv6 over IPv4? That approach seems to be pretty standard in many applications (e.g. browsers).

comment:6 Changed 3 years ago by jow

Read my comment. There is no downside, just the fact that the used resolver functions do prefer IPv4. I didn't get around to change that yet. Feel free to send patches if you beat me to it.

Changed 3 years ago by mwarning

Let ntpd prefer IPv6 over IPv4

comment:7 Changed 3 years ago by mwarning

The patch still needs testing.

comment:8 Changed 3 years ago by mwarning

Ok, the patch looks ok to me (reply from IPv6 address):

root@OpenWrt:~# /usr/sbin/ntpd -dn -q -p 2.openwrt.pool.ntp.org
ntpd: resolved peer 2.openwrt.pool.ntp.org to 2001:418:3ff::53
ntpd: sending query to 2001:418:3ff::53
ntpd: reply from 2001:418:3ff::53: offset:+0.002574 delay:0.099571 status:0x24 strat:2 refid:0x82951115 rootdelay:0.013519 reach:0x01
ntpd: resolved peer 2.openwrt.pool.ntp.org to 213.154.229.24
ntpd: sending query to 213.154.229.24
ntpd: send failed: Network is unreachable
ntpd: resolved peer 2.openwrt.pool.ntp.org to 2a00:1ca8:e:4::b3b6:1d74
ntpd: sending query to 2a00:1ca8:e:4::b3b6:1d74
ntpd: reply from 2a00:1ca8:e:4::b3b6:1d74: offset:-0.003210 delay:0.093959 status:0x24 strat:3 refid:0x29518a21 rootdelay:0.005768 reach:0x05
ntpd: resolved peer 2.openwrt.pool.ntp.org to 85.255.214.66
ntpd: sending query to 85.255.214.66
ntpd: send failed: Network is unreachable
ntpd: resolved peer 2.openwrt.pool.ntp.org to 2001:418:3ff::53
ntpd: sending query to 2001:418:3ff::53

comment:9 follow-up: Changed 3 years ago by jow

The patch looks good to me, I'll give it a try as well.

comment:10 Changed 3 years ago by mwarning

An alternative would be to let host2sockaddr return a IPv6 or IPv4 address at random if the protocol is unspecified (as host2sockaddr does not retain a state).

comment:11 in reply to: ↑ 9 Changed 18 months ago by anonymous

Replying to jow:

The patch looks good to me, I'll give it a try as well.

I think this patch should be integrated in LEDE.

Add Comment

Modify Ticket

Action
as accepted .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.