Determine fastest APT server using the Internet Control Message Protocol (ICMP).

Install netselect-apt utility.

$ sudo apt install netselect netselect-apt

Display usage information.

$ netselect --help
Usage: netselect-apt [OPTIONS] [ debian_release ]
       debian_release is one of stable, testing, unstable, experimental
       or a codename etch, lenny, squeeze, wheezy, jessie, stretch, sid
Options:
   -a, --arch ARCH        Use mirrors containing arch (amd64)
   -s, --sources          Include deb-src lines in generated file (no)
   -i, --infile INFILE    Use INFILE as the input file (temp file)
   -o, --outfile OUTFILE  Use OUTFILE as the output file (sources.list)
   -n, --nonfree          Use also non-free packages in OUTFILE (no)
   -f, --ftp              Use FTP as the protocol for OUTFILE (http)
   -t, --tests #          Number of hosts to test (10)
   -c, --country COUNTRY  Restrict search to servers in that country
   -d, --debug            Enable debugging

Create sources.list for the fastest Debian mirrors in Germany using official mirror list.

$ netselect-apt --arch amd64 --nonfree --country de --outfile /tmp/sources.list
Using distribution stable.
Retrieving the list of mirrors from www.debian.org...

URL transformed to HTTPS due to an HSTS policy
--2022-03-30 23:24:03--  https://www.debian.org/mirror/mirrors_full
Resolving www.debian.org (www.debian.org)... 130.89.148.77, 2001:67c:2564:a119::77
Connecting to www.debian.org (www.debian.org)|130.89.148.77|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 113671 (111K) [text/html]
Saving to: ‘/tmp/netselect-apt.Owg2Hv’

/tmp/netselect-apt.Owg2Hv                  100%[========================================================================================>] 111.01K  --.-KB/s    in 0.1s    

2022-03-30 23:24:04 (1.08 MB/s) - ‘/tmp/netselect-apt.Owg2Hv’ saved [113671/113671]

Choosing a main Debian mirror using netselect.
(will filter only for mirrors in country de)
netselect: 7 (7 active) nameserver request(s)...         
Duplicate address 141.76.2.4 (http://ftp.de.debian.org/debian/, http://debian.inf.tu-dresden.de/debian/); keeping only under first name.
netselect: 6 (6 active) nameserver request(s)...       
Duplicate address 137.226.34.46 (http://ftp.halifax.rwth-aachen.de/debian/, http://ftp2.de.debian.org/debian/); keeping only under first name.
Running netselect to choose 10 out of 37 addresses.     
......................................................................................................................................................................................................................................................................................................................................................
The fastest 10 servers seem to be:

	http://mirrors.xtom.de/debian/
	http://debian.mirror.iphh.net/debian/
	http://ftp.gwdg.de/debian/
	http://ftp.tu-clausthal.de/debian/
	http://de.mirrors.clouvider.net/debian/
	http://debian.uni-duisburg-essen.de/debian/
	http://ftp.uni-stuttgart.de/debian/
	http://mirror.ipb.de/debian/
	http://ftp-stud.hs-esslingen.de/debian/
	http://ftp.uni-stuttgart.de/debian/

Of the hosts tested we choose the fastest valid for http:
        http://mirrors.xtom.de/debian/

Writing /tmp/sources.list.
Done.

Inspect created sources.list file.

$ cat /tmp/sources.list 
# Debian packages for stable
deb http://mirrors.xtom.de/debian/ stable main contrib non-free
# Uncomment the deb-src line if you want 'apt-get source'
# to work with most packages.
# deb-src http://mirrors.xtom.de/debian/ stable main contrib non-free

# Security updates for stable
deb http://security.debian.org/ stable/updates main contrib non-free

You can create your own mirror list.

$ cat << EOF | tee mirror.list
<h3><a name="DE">Germany</a></h3>

Site: ftp.fau.de
Packages over HTTP: <a rel="nofollow" href="http://ftp.fau.de/debian/">/debian/</a>
Includes architectures: amd64 arm64 armel armhf i386 mips mips64el mipsel powerpc ppc64el s390x
<br><br>

Site: ftp-stud.hs-esslingen.de
Packages over HTTP: <a rel="nofollow" href="http://ftp-stud.hs-esslingen.de/debian/">/debian/</a>
Includes architectures: amd64 arm64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc ppc64el s390 s390x
<br><br>


<h3><a name="PL">Poland</a></h3>

Site: ftp.icm.edu.pl
Packages over HTTP: <a rel="nofollow" href="http://ftp.icm.edu.pl/pub/Linux/debian/">/pub/Linux/debian/</a>
Includes architectures: amd64 arm64 armel armhf i386 mips mips64el mipsel powerpc ppc64el s390x
<br><br>
EOF
<h3><a name="DE">Germany</a></h3>

Site: ftp.fau.de
Packages over HTTP: <a rel="nofollow" href="http://ftp.fau.de/debian/">/debian/</a>
Includes architectures: amd64 arm64 armel armhf i386 mips mips64el mipsel powerpc ppc64el s390x
<br><br>

Site: ftp-stud.hs-esslingen.de
Packages over HTTP: <a rel="nofollow" href="http://ftp-stud.hs-esslingen.de/debian/">/debian/</a>
Includes architectures: amd64 arm64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc ppc64el s390 s390x
<br><br>


<h3><a name="PL">Poland</a></h3>

Site: ftp.icm.edu.pl
Packages over HTTP: <a rel="nofollow" href="http://ftp.icm.edu.pl/pub/Linux/debian/">/pub/Linux/debian/</a>
Includes architectures: amd64 arm64 armel armhf i386 mips mips64el mipsel powerpc ppc64el s390x
<br><br>

Use created mirror list to simply determine the fastest server.

$ netselect-apt --arch amd64 --nonfree --infile mirror.list --outfile /dev/null
Using distribution stable.
mirror.list has been found.
I'll use that, rather than downloading it again.

Choosing a main Debian mirror using netselect.
Running netselect to choose 10 out of 3 addresses.      
...................................
Only found  3 hosts out of 10 requested.
The fastest 10 servers seem to be:

	http://ftp.icm.edu.pl/pub/Linux/debian/
	http://ftp-stud.hs-esslingen.de/debian/
	http://ftp.fau.de/debian/

Of the hosts tested we choose the fastest valid for http:
        http://ftp.icm.edu.pl/pub/Linux/debian/

Writing /dev/null.
Done.
ko-fi