Why there is a time difference between 'traceroute <hostname>' and 'traceroute -4 <hostname>' command ?
Environment
- Red Hat Enterprise Linux(RHEL).
- traceroute.
Issue
- Why there is a time difference between
traceroute <hostname>andtraceroute -4 <hostname>command?
Resolution
- This is an expected behavior. When
traceroute <hostname>command is executed it will check via aDNSresolver for bothIPV4(A)andIPV6(AAAA)address. Whereas with-4optiontraceroutewill only resolve forIPv4(A). - For more information refer
#man traceroute.
Root Cause
-
While executing the
traceroute <hostname>command, it will try to resolve the hostname by using bothIPv4andIPv6addresses andIPv4address has higher precedence. -
The server will check
IPV6 DNSlookups even whenIPV6is disabled inRHEL. Why are IPV6 DNS lookups done even when IPV6 is disabled in Red Hat Enterprise Linux?
Diagnostic Steps
- From the
stracewe can see process is holding for 2 seconds at apolltrace.
<snip>
23704 08:45:20 connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.1.1")}, 28) = 0
23704 08:45:20 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
23704 08:45:20 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
23704 08:45:20 poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
23704 08:45:20 sendto(3, "\xf3\xb5\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x09\x65\x70\x73\x76\x61\x31\x37\x30\x32\x0a\x77\x65\x6c\x6c\x73\x66\x61\x72\x67"..., 42, MSG_NOSIGNAL, NULL, 0) = 42
23704 08:45:20 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}]) ====>>> 2 second delay
23704 08:45:22 ioctl(3, FIONREAD, [42]) = 0
<snip>
- Again there is 2 seconds delay with the
DNS Ipandpoll.pollis delaying means it is checking forIPV6 DNSlookups from theDNSserver.
<snip>
23704 08:45:22 connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.1.1")}, 28) = 0
23704 08:45:22 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
23704 08:45:22 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
23704 08:45:22 poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
23704 08:45:22 sendto(3, "\xf3\xb5\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x09\x65\x70\x73\x76\x61\x31\x37\x30\x32\x0a\x77\x65\x6c\x6c\x73\x66\x61\x72\x67"..., 42, MSG_NOSIGNAL, NULL, 0) = 42
23704 08:45:22 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
23704 08:45:24 ioctl(3, FIONREAD, [42]) = 0
23704 08:45:24 recvfrom(3, "\xf3\xb5\x81\x82\x00\x01\x00\x00\x00\x00\x00\x00\x09\x65\x70\x73\x76\x61\x31\x37\x30\x32\x0a\x77\x65\x6c\x6c\x73\x66\x61\x72\x67"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.2.4")}, [16]) = 42 ======>>> 2 second delay
23704 08:45:24 close(3) = 0
</snip>
- This can be confirmed by using captured
tcpdump.
400 2017-12-04 00:35:02.302430 192.168.1.2 192.168.1.1 DNS 84 Standard query AAAA server.example.com
626 2017-12-04 00:35:04.887139 192.168.1.1 192.168.1.2 DNS 84 Standard query response, Server failure ===>>>
853 2017-12-04 00:35:07.982493 192.168.1.2 192.168.1.1 DNS 84 Standard query AAAA server.example.com
998 2017-12-04 00:35:09.751530 192.168.1.2 192.168.1.2 DNS 84 Standard query response, Server failure ===>>>
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
