En sistemas Debian y derivados, la herramienta netselect-apt crea el archivo sources.list, para utilizar con el gestor de paquetes APT en la distribución especificada, seleccionando el mirror más rápido.

netselect-apt descarga la lista de mirrors de Debian utilizando wget y elige el mirror más rápido utilizando netselect. Además (si está disponible curl) verifica que sean válidos.

Para determinar cuál de los mirrors es el más rápido, netselect utiliza el protocolo ICMP (ping) para seleccionar aquel con mejor tiempo de respuesta. Esto implica que, para utilizar esta herramienta, es necesario contar con acceso ICMP hacia el exterior (permitido por el firewall local y perimetral).

Para instalar netselect-apt, simplemente ejecutar:

# apt-get install netselect-apt

Una vez determinado el mirror más rápido, netselect-apt construye el nuevo archivo sources.list. Si éste ya existe en el directorio actual, crea una copia de seguridad.

Ejemplo de uso

Cambiar al directorio /etc/apt:

root@linuxito:~# cd /etc/apt/

El archivo sources.list actualmente posee el siguiente contenido:

root@linuxito:/etc/apt# cat sources.list
deb http://ftp.debian.org/debian wheezy main contrib non-free
deb http://security.debian.org wheezy/updates main contrib non-free
deb http://ftp.debian.org/debian wheezy-backports main

Ejecutar netselect-apt en el directorio actual para crear el nuevo sources.list, utilizando el mirror más rápido (relativo a la ubicación del servidor):

root@linuxito:/etc/apt# netselect-apt 
Using distribution stable.
Retrieving the list of mirrors from www.debian.org...

--2016-11-09 07:08:14--  http://www.debian.org/mirror/mirrors_full
Resolving www.debian.org (www.debian.org)... 2001:4f8:8:36::1deb:22, 128.31.0.62, 149.20.20.22
Connecting to www.debian.org (www.debian.org)|2001:4f8:8:36::1deb:22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 301525 (294K) [text/html]
Saving to: `/tmp/netselect-apt.X2IxNn'

100%[=================================================================>] 301,525     1.22M/s   in 0.2s    

2016-11-09 07:08:14 (1.22 MB/s) - `/tmp/netselect-apt.X2IxNn' saved [301525/301525]

Choosing a main Debian mirror using netselect.
netselect: 427 (24 active) nameserver request(s)...       
Duplicate address 218.100.43.30 (http://mirror.waia.asn.au/debian/, http://ftp.au.debian.org/debian/); keeping only under first name.
netselect: 409 (24 active) nameserver request(s)...       
Duplicate address 207.210.46.249 (http://207.210.46.249/debian/, http://debian.mirror.rafal.ca/debian/); keeping only under first name.
netselect: 407 (23 active) nameserver request(s)...       
Duplicate address 192.175.120.168 (http://192.175.120.168/debian/, http://debian.mirror.iweb.ca/debian/); keeping only under first name.
netselect: 404 (23 active) nameserver request(s)...       
Duplicate address 195.234.45.114 (http://mirror.as35701.net/debian/, http://ftp.be.debian.org/debian/); keeping only under first name.
netselect: 373 (23 active) nameserver request(s)...       
Duplicate address 129.132.53.171 (http://ftp.ch.debian.org/debian/, http://debian.ethz.ch/debian/); keeping only under first name.
netselect: 367 (23 active) nameserver request(s)...       
Duplicate address 137.226.34.46 (http://ftp2.de.debian.org/debian/, http://ftp.halifax.rwth-aachen.de/debian/); keeping only under first name.
netselect: 365 (23 active) nameserver request(s)...       
Duplicate address 213.129.232.18 (http://ftp.at.debian.org/debian/, http://debian.sil.at/debian/); keeping only under first name.
netselect: 360 (23 active) nameserver request(s)...       
Duplicate address 101.0.120.90 (http://debian.mirror.digitalpacific.com.au/debian/, http://mirror.crucial.com.au/debian/); keeping only under first name.
netselect: 321 (23 active) nameserver request(s)...       
Duplicate address 200.236.31.3 (http://debian.c3sl.ufpr.br/debian/, http://ftp.br.debian.org/debian/); keeping only under first name.
netselect: 312 (23 active) nameserver request(s)...       
Duplicate address 212.27.32.66 (http://ftp.fr.debian.org/debian/, http://debian.proxad.net/debian/); keeping only under first name.
netselect: 301 (24 active) nameserver request(s)...       
Duplicate address 82.194.78.250 (http://ftp.es.debian.org/debian/, http://ulises.hostalia.com/debian/); keeping only under first name.
netselect: 293 (23 active) nameserver request(s)...       
Duplicate address 195.80.123.154 (http://ftp.aso.ee/debian/, http://ftp.ee.debian.org/debian/); keeping only under first name.
netselect: 289 (23 active) nameserver request(s)...       
Duplicate address 138.231.176.11 (http://webb.ens-cachan.fr/debian/, http://debian.ens-cachan.fr/ftp/debian/); keeping only under first name.
netselect: 276 (23 active) nameserver request(s)...       
Duplicate address 78.129.164.123 (http://ftp.uk.debian.org/debian/, http://free.hands.com/debian/); keeping only under first name.
netselect: 263 (23 active) nameserver request(s)...       
Duplicate address 147.102.222.211 (http://ftp.gr.debian.org/debian/, http://debian.noc.ntua.gr/debian/); keeping only under first name.
netselect: 238 (23 active) nameserver request(s)...       
Duplicate address 193.1.193.65 (http://debian.heanet.ie/debian/, http://ftp.ie.debian.org/debian/); keeping only under first name.
netselect: 228 (23 active) nameserver request(s)...       
Duplicate address 166.111.206.63 (http://mirrors.tuna.tsinghua.edu.cn/debian/, http://ftp2.cn.debian.org/debian/); keeping only under first name.
netselect: 225 (23 active) nameserver request(s)...       
Duplicate address 161.53.160.11 (http://ftp.hr.debian.org/debian/, http://debian.carnet.hr/debian/); keeping only under first name.
netselect: 221 (23 active) nameserver request(s)...       
Duplicate address 194.105.226.20 (http://debian.simnet.is/debian/, http://ftp.is.debian.org/debian/); keeping only under first name.
netselect: 207 (23 active) nameserver request(s)...       
Duplicate address 195.228.252.133 (http://ftp.fsn.hu/debian/, http://ftp.hu.debian.org/debian/); keeping only under first name.
netselect: 201 (23 active) nameserver request(s)...       
Duplicate address 213.156.32.111 (http://debian.fastweb.it/debian/, http://ftp.it.debian.org/debian/); keeping only under first name.
netselect: 197 (23 active) nameserver request(s)...       
Duplicate address 150.65.7.130 (http://ftp.jaist.ac.jp/debian/, http://ftp.jp.debian.org/debian/); keeping only under first name.
netselect: 193 (23 active) nameserver request(s)...       
Duplicate address 178.17.160.48 (http://mirror.as43289.net/debian/, http://ftp.md.debian.org/debian/); keeping only under first name.
netselect: 182 (24 active) nameserver request(s)...       
Duplicate address 132.248.182.159 (http://ftp.mx.debian.org/debian/, http://mmc.geofisica.unam.mx/debian/); keeping only under first name.
netselect: 175 (23 active) nameserver request(s)...       
Duplicate address 145.220.21.40 (http://ftp.surfnet.nl/os/Linux/distr/debian/, http://ftp.nluug.nl/pub/os/Linux/distr/debian/); keeping only under first name.
netselect: 170 (23 active) nameserver request(s)...       
Duplicate address 158.129.159.169 (http://debian.mirror.vu.lt/debian/, http://ftp.lt.debian.org/debian/); keeping only under first name.
netselect: 166 (23 active) nameserver request(s)...       
Duplicate address 122.252.188.75 (http://mirror.akl.tmnetwork.co.nz/debian/, http://mirror.wlg.tmnetwork.co.nz/debian/); keeping only under first name.
netselect: 145 (23 active) nameserver request(s)...       
Duplicate address 62.44.96.11 (http://ftp.bg.debian.org/debian/, http://ftp.uni-sofia.bg/debian/); keeping only under first name.
netselect: 144 (23 active) nameserver request(s)...
Duplicate address 78.96.7.8 (http://ftp.ro.debian.org/debian/, http://ftp.upcnet.ro/debian/); keeping only under first name.
netselect: 138 (22 active) nameserver request(s)...       
Duplicate address 85.143.112.112 (http://ftp.ru.debian.org/debian/, http://mirror.mephi.ru/debian/); keeping only under first name.
netselect: 124 (23 active) nameserver request(s)...       
Duplicate address 210.23.25.77 (http://ftp.sg.debian.org/debian/, http://mirror.0x.sg/debian/); keeping only under first name.
netselect: 123 (23 active) nameserver request(s)...
Duplicate address 195.14.50.21 (http://mirror2.corbina.ru/debian/, http://ftp.corbina.net/debian/); keeping only under first name.
netselect: 121 (24 active) nameserver request(s)...       
Duplicate address 130.239.18.165 (http://130.239.18.165/debian/, http://130.239.18.165/debian/); keeping only under first name.
netselect: 119 (22 active) nameserver request(s)...
Duplicate address 130.239.18.173 (http://130.239.18.173/debian/, http://130.239.18.173/debian/); keeping only under first name.
netselect: 117 (23 active) nameserver request(s)...       
Duplicate address 192.240.106.18 (http://mirrors-uk.go-parts.com/debian/, http://mirrors-ru.go-parts.com/debian/); keeping only under first name.
netselect: 115 (23 active) nameserver request(s)...       
Duplicate address 130.239.18.165 (http://130.239.18.165/debian/, http://130.239.18.165/debian/); keeping only under first name.
netselect: 114 (23 active) nameserver request(s)...
Duplicate address 130.239.18.173 (http://130.239.18.173/debian/, http://130.239.18.173/debian/); keeping only under first name.
netselect: 109 (23 active) nameserver request(s)...       
Duplicate address 130.239.18.165 (http://130.239.18.165/debian/, http://130.239.18.165/debian/); keeping only under first name.
netselect: 108 (23 active) nameserver request(s)...
Duplicate address 130.239.18.173 (http://130.239.18.173/debian/, http://130.239.18.173/debian/); keeping only under first name.
netselect: 107 (24 active) nameserver request(s)...       
Duplicate address 115.126.160.7 (http://ftp.nc.debian.org/debian/, http://debian.nautile.nc/debian/); keeping only under first name.
netselect: 106 (23 active) nameserver request(s)...
Duplicate address 193.140.100.100 (http://ftp.linux.org.tr/debian/, http://ftp.tr.debian.org/debian/); keeping only under first name.
netselect: 100 (23 active) nameserver request(s)...       
Duplicate address 190.86.223.16 (http://debian.salud.gob.sv/debian/, http://ftp.sv.debian.org/debian/); keeping only under first name.
netselect: 94 (23 active) nameserver request(s)...       
Duplicate address 213.157.243.77 (http://debmirror.amis.net/debian/, http://ftp.si.debian.org/debian/); keeping only under first name.
netselect: 89 (24 active) nameserver request(s)...       
Duplicate address 193.140.100.100 (http://ftp.linux.org.tr/debian/, http://debian.doratelekom.com/debian/); keeping only under first name.
netselect: 87 (22 active) nameserver request(s)...
Duplicate address 128.30.2.26 (http://128.30.2.26/debian/, http://debian.csail.mit.edu/debian/); keeping only under first name.
netselect: 87 (24 active) nameserver request(s)...
Duplicate address 62.168.95.115 (http://ftp.debian.sk/debian/, http://ftp.sk.debian.org/debian/); keeping only under first name.
netselect: 85 (23 active) nameserver request(s)...       
Duplicate address 202.8.44.105 (http://ftp.citylink.co.nz/debian/, http://ftp.nz.debian.org/debian/); keeping only under first name.
netselect: 81 (23 active) nameserver request(s)...       
Duplicate address 128.61.240.89 (http://128.61.240.89/debian/, http://debian.gtisc.gatech.edu/debian/); keeping only under first name.
netselect: 69 (23 active) nameserver request(s)...       
Duplicate address 91.200.60.59 (http://debian.org.ua/debian/, http://ftp2.debian.org.ua/debian/); keeping only under first name.
netselect: unknown host mirrors.e2wsolutions.com            
netselect: 46 (22 active) nameserver request(s)...       
Duplicate address 64.50.236.52 (http://64.50.236.52/debian/, http://64.50.236.52/debian/); keeping only under first name.
netselect: 46 (24 active) nameserver request(s)...
Duplicate address 64.50.233.100 (http://64.50.233.100/debian/, http://64.50.233.100/debian/); keeping only under first name.
netselect: 33 (24 active) nameserver request(s)...       
Duplicate address 208.80.154.15 (http://208.80.154.15/debian/, http://mirrors.wikimedia.org/debian/); keeping only under first name.
netselect: 23 (22 active) nameserver request(s)...       
Duplicate address 91.200.60.59 (http://debian.org.ua/debian/, http://ftp.ua.debian.org/debian/); keeping only under first name.
netselect: unknown host debian.asis.io                      
netselect: 15 (15 active) nameserver request(s)...       
Duplicate address 197.155.77.1 (http://mirror.liquidtelecom.com/debian/debian/, http://mirror.zol.co.zw/debian/); keeping only under first name.
netselect: 12 (12 active) nameserver request(s)...       
Duplicate address 202.141.176.110 (http://ftp.cn.debian.org/debian/, http://mirrors.ustc.edu.cn/debian/); keeping only under first name.
Running netselect to choose 10 out of 408 addresses.     
..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
The fastest 10 servers seem to be:

        http://ftp.us.debian.org/debian/
        http://mirror.cogentco.com/debian/
        http://mirrors.advancedhosters.com/debian/
        http://ftp.us.debian.org/debian/
        http://mirror.us.leaseweb.net/debian/
        http://debian.ec.as6453.net/debian/
        http://ftp.us.debian.org/debian/
        http://mirror.fdcservers.net/debian/
        http://mirrors.evowise.com/debian/
        http://mirrors-usa.go-parts.com/debian/

Of the hosts tested we choose the fastest valid for HTTP:
        http://ftp.us.debian.org/debian/

Writing sources.list.
sources.list exists, moving to sources.list.1478693325
Done.

Se observa que el mirror más rápido desde la ubicación de este servidor es "http://ftp.us.debian.org/debian/". Luego netselect-apt crea el nuevo archivo sources.list y guarda una copia de respaldo (archivo sources.list.1478693325):

root@linuxito:/etc/apt# ls -l | grep sources
-rw-r--r-- 1 root root  328 Nov  9 07:08 sources.list
-rw-r--r-- 1 root root  185 Nov  9 07:07 sources.list.1478693325
drwxr-xr-x 2 root root 4096 Jun 12  2014 sources.list.d

El contenido del nuevo archivo sources.list es:

root@linuxito:/etc/apt# cat sources.list
# Debian packages for stable
deb http://ftp.us.debian.org/debian/ stable main contrib
# Uncomment the deb-src line if you want 'apt-get source'
# to work with most packages.
# deb-src http://ftp.us.debian.org/debian/ stable main contrib

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

Notar que se ha perdido el repositorio de backports para Wheezy y también los paquetes "non-free". También notar que cambió "wheezy" por "stable". Esto último es muy peligroso y debe ser corregido inmediatamente:

# sed -i 's/stable/wheezy/g' /etc/apt/sources.list

Desconozco por qué hizo esto. Supongo que es el comportamiento por defecto.

Es posible indicarle a netselect-apt que use agregue los paquetes "non-free" en la nueva configuración a través de la opción --nonfree. Lo mismo para los fuentes a través de la opción --sources. Sin embargo, no hay una opción para los backports, por lo que es necesario editar el archivo luego de forma manual.

# netselect-apt --nonfree

Agregar los backports (cambiar el mirror de acuerdo a la salida de netselect-apt):

# (echo; echo "deb http://ftp.us.debian.org/debian/ wheezy-backports main") >> sources.list

Verificar el funcionamiento ejecutando:

# apt-get update && apt-get upgrade

Para mayor seguridad, es recomendable trabajar sobre una copia del archivo sources.list y luego cambiar manualmente el mirror más rápido según lo detectado por netselect-apt.

Referencias

man netselect-apt
man netselect


Tal vez pueda interesarte


Compartí este artículo