October 18, 2013 Leave a comment
I haven’t had any significant Linux problems or new requirements in the last few months, hence no new posts here. My last real problem was back in June 2013 when I rolled my Gentoo installation to latest using Portage and found that, whenever I launched Firefox, it displayed the ‘Server not found’ page and I had to click ‘Try Again’, and then Firefox displayed the expected Web site. From then onwards, Firefox would work as expected until I exited the application. Thunderbird was also unable to access e-mail servers on the first attempt after it was launched. The same thing happened in Sabayon Linux when I rolled to latest using Entropy a couple of days later. Anyway, here is how I fixed the problem in both distributions.
First I used Wireshark to see what was going on, and it transpired that Gentoo (and Sabayon) was sending an IPv4 request followed quickly by an IPv6 request, but the reply to the IPv6 request was being received first and was a ‘server not found’ message since my ISP does not support IPv6 and my router apparently does not handle IPv6 requests correctly. Gentoo (and Sabayon) then used an IPv4 address when I clicked ‘Try Again’ in the browser window, and thereafter Firefox always dispayed the expected Web sites.
I should point out that IPv6 is enabled in the kernels I use and I’ve never before had to disable IPv6 in Firefox (or system-wide) on the affected laptops. So why the change in functionality, I wonder?
With Wireshark capturing packets, when I launched Firefox I was seeing a server failure message indicating “AAAA” (IPv6) instead of “A” (IPv4). To stop this happening I could have chosen any one of the three following solutions:
1. I could have used about:config in Firefox (and Config Editor in Thunderbird) to change the value of
network.dns.disableIPv6 to true instead of false.
2. I could have disabled IPv6 system-wide by editing
/etc/modprobe.d/aliases.conf and uncommenting the line “
alias net-pf-10 off“.
3. I could have forced the
getaddrinfo() function in glibc to make the IPv4 and IPv6 requests sequentially rather than in parallel.
Just for the fun of it I chose the third option on a couple of my laptops, and, as they use NetworkManager, this is how I did it:
As you can see above, I added a two-line Bash script
06-dhclientoptions in the directory
/etc/NetworkManager/dispatcher.d/ that appends the line “
options single-request” (without the quotes) to the contents of the file
/etc/resolv.conf. The addition of the line “
options single-request” in
resolve.conf causes the
getaddrinfo() function in glibc to make the IPv4 and IPv6 requests sequentially rather than in parallel. With this change, Firefox and Thunderbird no longer have a problem accessing the Internet the first time they are launched.
From “man 5 resolv.conf” under “options”:
single-request (since glibc 2.10)
sets RES_SNGLKUP in _res.options. By default, glibc performs IPv4 and IPv6 lookups in parallel since version 2.9. Some appliance DNS servers cannot handle these queries properly and make the requests time out. This option disables the behavior and makes glibc perform the IPv6 and IPv4 requests sequentially (at the cost of some slowdown of the resolving process).
single-request-reopen (since glibc 2.9)
The resolver uses the same socket for the A and AAAA requests. Some hardware mistakenly sends back only one reply. When that happens the client system will sit and wait for the second reply. Turning this option on changes this behavior so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request.
I had to use NetworkManagerDispatcher to add the line “
options single-request” to
/etc/resolv.conf because NetworkManager overwrites
/etc/resolv.conf if you edit it manually.