Linux – Setting IPv4 as Preferred Protocol Over IPv6

getaddrinfoipv6linuxslackware

I'm using both IPv6 and IPv4 in a LAN network containing Slackware 13.0 boxes. How can I set IPv4 as preferred protocol on the workstations in this network? I want to use IPv6 either explicitly or when there are only AAAA records available. For example, if I try to open http://ipv6.org/ from Firefox, I will always connect via IPv6. The situation is the same with other applications. I tried creating /etc/gai.conf and adding the following to it:

precedence ::ffff:0:0/96  100

This should control the behavior of getaddrinfo(3) at least in Debian, but it didn't help on Slackware.

Any ideas will be appreciated. Thanks in advance!

Best Answer

According to the man page, inserting a precedence value in gai.conf disables the all the other default rules. Try setting all the rules as listed in RFC 3484 (10.3):

  Prefix        Precedence Label
  ::1/128               50     0
  ::/0                  40     1
  2002::/16             30     2
  ::/96                 20     3
  ::ffff:0:0/96        100     4