Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

How to prefer IPv4 over IPv6 in Ubuntu and CentOS

We've had this question come in a lot, specifically via chat.  The reason you may want to do this is to save some processing and resource utilization.  In Ubuntu, if you don't modify this, it will do a AAAA DNS lookup before A record lookups.

Ubuntu:

You can change this by editing the precedence blocks in /etc/gai.conf.  Locate this line:

#precedence ::ffff:0:0/96  100

And un-comment it to look like:

precedence ::ffff:0:0/96  100

CentOS:

You'll need to modify the /etc/gai.conf to look like:

label       ::1/128        0
label       ::/0           1
label       2002::/16      2
label       ::/96          3
label       ::ffff:0:0/96  4
precedence  ::1/128        50
precedence  ::/0           40
precedence  2002::/16      30
precedence  ::/96          20
precedence  ::ffff:0:0/96  100

That should be it.  That should set up the precedence for you so that your server(s) will use IPv4 over IPv6 without disabling IPv6 on the server. :)

Let me know if this helps or if you have any questions!


Regards,

Alison Oster
Technical Community Manager