tisdag 18 september 2012

Make linux prefer IPv4 connections

Sometimes a DNS name resolves to both an IPv6 and and IPv4 address.  How do you force a program to choose for instance IPv4 over IPv6.

The answer is to change the file /etc/gai.conf which controls the getaddrinfo() (see man gai.conf)

For instance, append

precedence ::ffff:0:0/96  100
at the end of /etc/gai.conf to give high priority to A records.  The filters can also be more specific and made to apply only to specific addresses or subnets.  It doesn't seem to be able to change on a per-process basis with this approach (and of course it requires you to have root privileges to modify /etc/gai.conf).

Thanks to Lmwangi at http://unix.stackexchange.com/questions/9940/convince-apt-get-not-to-use-ipv6-method

Inga kommentarer:

Skicka en kommentar