How does Debian select or prioritize IPv4 and IPv6 connections?

5,769

Turns out that it's about configuration of getaddrinfo, which is controlled at /etc/gai.conf.

More information about how it can be solved: https://askubuntu.com/questions/32298/prefer-a-ipv4-dns-lookups-before-aaaaipv6-lookups

Share:
5,769

Related videos on Youtube

Hasan Berkay Cagir
Author by

Hasan Berkay Cagir

Updated on September 18, 2022

Comments

  • Hasan Berkay Cagir
    Hasan Berkay Cagir over 1 year

    I'm going to explain my question with an example. I have two servers, A and B, both runs Debian 7.8, both have dual-stack connection to the Internet (I don't know if it matters but they even have the same amount of IPv6 addresses) and they both have the same version of whois installed (without any config file).

    Now, when I whois google.fr (I chose whois.nic.fr because it shows the IP you're connecting from) from server A, I get this response header:

    %%
    %% This is the AFNIC Whois server.
    %%
    %% complete date format : DD/MM/YYYY
    %% short date format    : DD/MM
    %% version              : FRNIC-2.5
    %%
    %% Rights restricted by copyright.
    %% See http://www.afnic.fr/afnic/web/mentions-legales-whois_en
    %%
    %% Use '-h' option to obtain more information about this service.
    %%
    %% [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx REQUEST] >> -V Md5.1 google.fr
    %%
    %% RL Net [##########] - RL IP [#########.]
    %%
    

    As you can see, whois used a IPv6 address to connect to whois.nic.fr.

    But, when I do the same at server B, I get this response header:

    %%
    %% This is the AFNIC Whois server.
    %%
    %% complete date format : DD/MM/YYYY
    %% short date format    : DD/MM
    %% version              : FRNIC-2.5
    %%
    %% Rights restricted by copyright.
    %% See http://www.afnic.fr/afnic/web/mentions-legales-whois_en
    %%
    %% Use '-h' option to obtain more information about this service.
    %%
    %% [xx.x.xxx.xxx REQUEST] >> -V Md5.1 google.fr
    %%
    %% RL Net [##########] - RL IP [#########.]
    %%
    

    As you can see now, whois used IPv4 at server B.

    Why doesn't server B use IPv6 when connecting to the whois server? They surely both have connection with IPv6 but one of them chooses to use IPv6 where one does not. Is there any reason for the OS to prioritize connection types?

    • Admin
      Admin almost 2 years
      Seeing this in a debian 10 box as well, and gai.conf is default, modifying it makes no difference, I wonder what is going on.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 9 years
    Hmmm, no, not really. In practicec, it's usually the DNS response that makes the difference (assuming the application supports both), and that's strongly influence by the OS configuration.
  • Hasan Berkay Cagir
    Hasan Berkay Cagir about 9 years
    Both servers can reach whois.nic.fr via IPv4/IPv6 without any problems. And this made me think that an OS configuration prioritizing something and whois can't use IPv6.
  • Admin
    Admin almost 2 years
    The application makes a DNS request, the OS should order the replies with AAAA records first (specified in RFC) applications should be, and are written to handle the protocols equally (unless we are talking about happy eyeballs) If an OS prefers v4 over v6, then it is a misconfiguration (RFC wise)