[Bug 1853669] Re: systemd resolves own hostname to link local ipv6 address
Andreas L
avl.ramschbox at gmx.at
Fri Dec 6 10:48:02 UTC 2019
Here is some more info, namely an "strace" of the systemd-resolved
program.
(An "lsof"-excerpt with the open channels follows the trace-log, to make
sense of filedescriptors)
In a nutshell: at some point, it receives the inet6 address "fe80::4687:fcff:fe9e:4ac7" in an "recvmsg" call on FD 9, which lsof prints as:
"systemd-r 4966 systemd-resolve 9u netlink 0t0 15693998 ROUTE"
I don't understand what lsof tries to tell me here, but naively I'd assume that systemd-resolved also queries the routing table, and for that I also attach the output of "route -n -6" at the end of this message.
strace: Process 4966 attached
epoll_wait(4, [{EPOLLIN, {u32=3769468528, u64=94647668803184}}], 14, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=930758302}) = 0
recvfrom(12, NULL, 0, MSG_PEEK|MSG_TRUNC, NULL, NULL) = 21
recvmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(55365), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=128->16, msg_iov=[{iov_base="j\204\1\0\0\1\0\0\0\0\0\0\3fpc\0\0\1\0\1", iov_len=3928}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("127.0.0.53")}}, {cmsg_len=20, cmsg_level=SOL_IP, cmsg_type=IP_TTL, cmsg_data=[64]}], msg_controllen=56, msg_flags=0}, 0) = 21
stat("/etc/hosts", {st_mode=S_IFREG|0644, st_size=356, ...}) = 0
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=324, ...}) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=931200245}) = 0
sendto(9, {{len=24, type=RTM_GETADDR, flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, seq=9, pid=0}, {ifa_family=AF_INET, ifa_prefixlen=32, ifa_flags=0, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=0}}, 24, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 16) = 24
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 256
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=[{{len=76, type=RTM_NEWADDR, flags=NLM_F_MULTI, seq=9, pid=4966}, {ifa_family=AF_INET, ifa_prefixlen=8, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_HOST, ifa_index=if_nametoindex("lo")}, [{{nla_len=8, nla_type=IFA_ADDRESS}, 127.0.0.1}, {{nla_len=8, nla_type=IFA_LOCAL}, 127.0.0.1}, {{nla_len=7, nla_type=IFA_LABEL}, "lo"}, {{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT}, {{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=3449, tstamp=3449}}]}, {{len=88, type=RTM_NEWADDR, flags=NLM_F_MULTI, seq=9, pid=4966}, {ifa_family=AF_INET, ifa_prefixlen=24, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=if_nametoindex("enp4s0")}, [{{nla_len=8, nla_type=IFA_ADDRESS}, 10.2.2.1}, {{nla_len=8, nla_type=IFA_LOCAL}, 10.2.2.1}, {{nla_len=8, nla_type=IFA_BROADCAST}, 10.2.2.255}, {{nla_len=11, nla_type=IFA_LABEL}, "enp4s0"}, {{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT}, {{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=3810, tstamp=3810}}]}, {{len=92, type=RTM_NEWADDR, flags=NLM_F_MULTI, seq=9, pid=4966}, {ifa_family=AF_INET, ifa_prefixlen=8, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=if_nametoindex("enp4s0")}, [{{nla_len=8, nla_type=IFA_ADDRESS}, 10.2.2.250}, {{nla_len=8, nla_type=IFA_LOCAL}, 10.2.2.250}, {{nla_len=8, nla_type=IFA_BROADCAST}, 10.255.255.255}, {{nla_len=13, nla_type=IFA_LABEL}, "enp4s0:1"}, {{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT}, {{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=10833228, tstamp=10833228}}]}], iov_len=5200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=0}, MSG_TRUNC) = 256
ppoll([{fd=9, events=POLLIN}], 1, {tv_sec=24, tv_nsec=999785000}, NULL, 8) = 1 ([{fd=9, revents=POLLIN}], left {tv_sec=24, tv_nsec=999783625})
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 20
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base={{len=20, type=NLMSG_DONE, flags=NLM_F_MULTI, seq=9, pid=4966}, 0}, iov_len=5200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=0}, MSG_TRUNC) = 20
sendmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(55365), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=16, msg_iov=[{iov_base="j\204\201\200\0\1\0\2\0\0\0\0\3fpc\0\0\1\0\1\300\f\0\1\0\1\0\0\0\0\0"..., iov_len=53}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("0.0.0.0")}}], msg_controllen=28, msg_flags=0}, 0) = 53
epoll_wait(4, [{EPOLLIN, {u32=3769468528, u64=94647668803184}}], 14, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=932073644}) = 0
recvfrom(12, NULL, 0, MSG_PEEK|MSG_TRUNC, NULL, NULL) = 21
recvmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(35665), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=128->16, msg_iov=[{iov_base="\16j\1\0\0\1\0\0\0\0\0\0\3fpc\0\0\34\0\1", iov_len=3928}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("127.0.0.53")}}, {cmsg_len=20, cmsg_level=SOL_IP, cmsg_type=IP_TTL, cmsg_data=[64]}], msg_controllen=56, msg_flags=0}, 0) = 21
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=324, ...}) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=932250666}) = 0
sendto(9, {{len=24, type=RTM_GETADDR, flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_DUMP, seq=10, pid=0}, {ifa_family=AF_INET6, ifa_prefixlen=128, ifa_flags=0, ifa_scope=RT_SCOPE_UNIVERSE, ifa_index=0}}, 24, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 16) = 24
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 144
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=[{{len=72, type=RTM_NEWADDR, flags=NLM_F_MULTI, seq=10, pid=4966}, {ifa_family=AF_INET6, ifa_prefixlen=128, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_HOST, ifa_index=if_nametoindex("lo")}, [{{nla_len=20, nla_type=IFA_ADDRESS}, ::1}, {{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=10601811, tstamp=10601811}}, {{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT}]}, {{len=72, type=RTM_NEWADDR, flags=NLM_F_MULTI, seq=10, pid=4966}, {ifa_family=AF_INET6, ifa_prefixlen=64, ifa_flags=IFA_F_PERMANENT, ifa_scope=RT_SCOPE_LINK, ifa_index=if_nametoindex("enp4s0")}, [{{nla_len=20, nla_type=IFA_ADDRESS}, fe80::4687:fcff:fe9e:4ac7}, {{nla_len=20, nla_type=IFA_CACHEINFO}, {ifa_prefered=4294967295, ifa_valid=4294967295, cstamp=10601811, tstamp=10601811}}, {{nla_len=8, nla_type=IFA_FLAGS}, IFA_F_PERMANENT}]}], iov_len=5200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=0}, MSG_TRUNC) = 144
ppoll([{fd=9, events=POLLIN}], 1, {tv_sec=24, tv_nsec=999834000}, NULL, 8) = 1 ([{fd=9, revents=POLLIN}], left {tv_sec=24, tv_nsec=999832412})
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 20
recvmsg(9, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=128->12, msg_iov=[{iov_base={{len=20, type=NLMSG_DONE, flags=NLM_F_MULTI, seq=10, pid=4966}, 0}, iov_len=5200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_NETLINK, cmsg_type=0x3}], msg_controllen=24, msg_flags=0}, MSG_TRUNC) = 20
sendmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(35665), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=16, msg_iov=[{iov_base="\16j\201\200\0\1\0\1\0\0\0\0\3fpc\0\0\34\0\1\300\f\0\34\0\1\0\0\0\0\0"..., iov_len=49}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("0.0.0.0")}}], msg_controllen=28, msg_flags=0}, 0) = 49
epoll_wait(4, [{EPOLLIN, {u32=3769468528, u64=94647668803184}}], 14, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=932976869}) = 0
recvfrom(12, NULL, 0, MSG_PEEK|MSG_TRUNC, NULL, NULL) = 21
recvmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(58010), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=128->16, msg_iov=[{iov_base="\375\377\1\0\0\1\0\0\0\0\0\0\3fpc\0\0\17\0\1", iov_len=3928}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("127.0.0.53")}}, {cmsg_len=20, cmsg_level=SOL_IP, cmsg_type=IP_TTL, cmsg_data=[64]}], msg_controllen=56, msg_flags=0}, 0) = 21
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=324, ...}) = 0
getrandom("\xef\x0d", 2, GRND_NONBLOCK) = 2
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=933163515}) = 0
openat(AT_FDCWD, "/run/systemd/netif/links/2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=324, ...}) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=933261481}) = 0
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=324, ...}) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 15
connect(15, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.2.2.3")}, 16) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 15, {EPOLLIN, {u32=3769485520, u64=94647668820176}}) = 0
write(15, "\357\r\1\0\0\1\0\0\0\0\0\0\3fpc\0\0\17\0\1", 21) = 21
timerfd_settime(14, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=1269408, tv_nsec=715848000}}, NULL) = 0
epoll_wait(4, [{EPOLLIN, {u32=3769485520, u64=94647668820176}}], 17, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1269407, tv_nsec=936528358}) = 0
recvfrom(15, NULL, 0, MSG_PEEK|MSG_TRUNC, NULL, NULL) = 21
recvmsg(15, {msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.2.2.3")}, msg_namelen=128->16, msg_iov=[{iov_base="\357\r\205\200\0\1\0\0\0\0\0\0\3fpc\0\0\17\0\1", iov_len=3928}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 21
epoll_ctl(4, EPOLL_CTL_DEL, 15, NULL) = 0
close(15) = 0
sendmsg(12, {msg_name={sa_family=AF_INET, sin_port=htons(58010), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=16, msg_iov=[{iov_base="\375\377\201\200\0\1\0\0\0\0\0\0\3fpc\0\0\17\0\1", iov_len=21}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=IP_PKTINFO, cmsg_data={ipi_ifindex=if_nametoindex("lo"), ipi_spec_dst=inet_addr("127.0.0.53"), ipi_addr=inet_addr("0.0.0.0")}}], msg_controllen=28, msg_flags=0}, 0) = 21
timerfd_settime(14, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=0, tv_nsec=0}}, NULL) = 0
epoll_wait(4,
filedescriptors by "lsof":
systemd-r 4966 systemd-resolve 0r CHR 1,3 0t0 6 /dev/null
systemd-r 4966 systemd-resolve 1u unix 0xffff9602c499f800 0t0 15693992 type=STREAM
systemd-r 4966 systemd-resolve 2u unix 0xffff9602c499f800 0t0 15693992 type=STREAM
systemd-r 4966 systemd-resolve 3u unix 0xffff9602c499c000 0t0 15693994 type=DGRAM
systemd-r 4966 systemd-resolve 4u a_inode 0,13 0 12693 [eventpoll]
systemd-r 4966 systemd-resolve 5u a_inode 0,13 0 12693 [signalfd]
systemd-r 4966 systemd-resolve 6u a_inode 0,13 0 12693 [timerfd]
systemd-r 4966 systemd-resolve 7r REG 0,4 0 16602 /proc/sys/kernel/hostname
systemd-r 4966 systemd-resolve 8r a_inode 0,13 0 12693 inotify
systemd-r 4966 systemd-resolve 9u netlink 0t0 15693998 ROUTE
systemd-r 4966 systemd-resolve 10u a_inode 0,13 0 12693 [timerfd]
systemd-r 4966 systemd-resolve 11u unix 0xffff9602c499e800 0t0 15693999 type=STREAM
systemd-r 4966 systemd-resolve 12u IPv4 15694000 0t0 UDP localhost:domain
systemd-r 4966 systemd-resolve 13u IPv4 15694001 0t0 TCP localhost:domain (LISTEN)
systemd-r 4966 systemd-resolve 14u a_inode 0,13 0 12693 [timerfd]
route -n -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
::/0 :: !n -1 1 1 lo
fe80::/64 :: U 256 2 1 enp4s0
::/0 :: !n -1 1 1 lo
::1/128 :: Un 0 10 698 lo
fe80::4687:fcff:fe9e:4ac7/128 :: Un 0 9 20 enp4s0
ff00::/8 :: U 256 9 354 enp4s0
::/0 :: !n -1 1 1 lo
At this point, I don't know what sort of routing-facility systemd-resolved consults, but either that or systemd-resolved's interpretation of that info seems to be the root-cause.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/1853669
Title:
systemd resolves own hostname to link local ipv6 address
Status in systemd package in Ubuntu:
Incomplete
Bug description:
I've got an ethernet-device that only has a configured ipv4 address,
and some auto-generated link-local (aka "scope link") ipv6 address.
Any tool doing a DNS query (and /lib/systemd/systemd-resolved is the
DNS-server listening on 127.0.0.53) for this host's hostname gets back
two addresses: the correct ipv4 address, and a broken ipv6 address.
Unlike on ipv4, it is possible for the same ipv6-address to be
assigned to multiple devices, and therefore the address is only valid
in the context of the eth-device.
Now, if "ifconfig" shows "inet6 fe80::4687:fcff:fe9e:4ac7 prefixlen 64 scopeid 0x20<link>"
then "fe80::4687:fcff:fe9e:4ac7" is NOT a connectable address, and syscall connect() typically fails with EINVAL.
To make it a valid address, it needs to be suffixed with a "%" and the device name, like:
fe80::4687:fcff:fe9e:4ac7%enp4s0
Either the resolver can return the link name attached to the address
separated with a "%" char, or it needs to ignore link-local inet6
addresses.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1853669/+subscriptions
More information about the foundations-bugs
mailing list