Why there is a time difference between 'traceroute <hostname>' and 'traceroute -4 <hostname>' command ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux(RHEL).
  • traceroute.

Issue

  • Why there is a time difference between traceroute <hostname> and traceroute -4 <hostname> command?

Resolution

  • This is an expected behavior. When traceroute <hostname> command is executed it will check via a DNS resolver for both IPV4(A) and IPV6(AAAA) address. Whereas with -4 option traceroute will only resolve for IPv4(A).
  • For more information refer #man traceroute.

Root Cause

Diagnostic Steps

  • From the strace we can see process is holding for 2 seconds at a poll trace.
<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 Ip and poll. poll is delaying means it is checking for IPV6 DNS lookups from the DNS server.
<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.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.