Force apt-get to connect via IPv4 or IPv6

Surely you are thinking: “IPv4 is ‘dead’, it does not make sense to force IPv4”, in an ideal world, you would be right .

But the reality is that a large part of the infrastructure of the network is not ready for IPv6.

My experience with apt-get on stable Debian in the UK has been painful.

Most of the “gateways” I have to manage in my work suffer from terribly slow connections when try-get tries to update repositories or download packages.

So we have had to configure such systems for queapt-get to make IPv4 connections instead of IPv6.

To tell apt-get to limit its connections to IPv4, the following parameter is used:

or IPv6:

Persistent option:

To make apt-get connect always via IPv4, we created the file 99force-ipv4 in /etc/apt/apt.conf.d/.

And we write the following content:

Save the file and from that moment all connections will be made through IPv4.

If instead of a 4 you put a 6, you will limit the connections only to IPv6.

The best way to know which one to choose is to simply try and see which one works best for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 4 =