NETSELECT(1)

πŸ“¦
version 0.3.ds1 Β· 3 versions
, in debian bookworm

🌸 NETSELECT(1) 🌸

okay bestie, gather round, because netselect(1) is a General Commands Manual page and it is genuinely one of the most useful little gremlins in your toolbox. it picks the fastest server for you, automatically, no cap. let's get into it πŸ’…


πŸŽ€ NAME πŸŽ€

netselect β€” choose the fastest server automatically ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

netselect [-v|-vv|-vvv|-vvvv] [-m HOPS] [-s SERVERS] [-t PACKETS [-I]
[-D] host ...

πŸ’– DESCRIPTION πŸ’–

so basically, netselect figures out a whole bunch of facts about every single host you hand it on the command line, and it does it way faster than you would if you sat there manually running ping and traceroute like some kind of medieval peasant. fr fr.

for each host, netselect works out:

  • the approximate ping time β€” though not as accurately as ping does, just so we're clear, it's giving estimates not precision
  • the number of network "hops" it takes to reach the target
  • the percentage of ping requests that actually got through successfully

then it takes all of that and calculates the "score" of each operational host based on these values. and here's the key thing: a lower score is better. in the end it prints one line showing the server with the best score. iconic behavior honestly πŸ‘‘

if the DNS name has multiple IP addresses associated with it, netselect will test each of the IP addresses independently. in that case, netselect will report the IP address of the fastest server β€” unless the -D option is used, of course. iykyk.

and one more thing before we move on: if the number of found hosts is not the same as the number you requested (using -s), netselect will emit a warning message. and if no hosts are found at all? the program will also end with an error return value. so, like, pay attention to that. πŸ’€


🌈 EXAMPLES 🌈

here's the vibe in action:

# netselect -vv ftp.fceia.unr.edu.ar ftp.kulnet.kuleuven.ac.be \
           ftp.cdrom.com ftp.debian.org ftp.de.debian.org

and this is the output:

ftp.fceia.unr.edu.ar         2792 ms  23 hops  100% ok ( 1/ 1) [ 9213]
ftp.kulnet.kuleuven.ac.be    9999 ms  30 hops    0% ok
ftp.cdrom.com                  94 ms   8 hops  100% ok (10/10) [  169]
ftp.debian.org                 46 ms  15 hops  100% ok (10/10) [  115]
ftp.de.debian.org            9999 ms  30 hops    0% ok
  115 ftp.debian.org

the value in brackets is the "score" of each operational host, based on these values. lower score = better, always. and that last line? that's the server with the best score, the winner, the main character 🫢

if we had not used -vv on the command line, only this last line would have been printed. so like, -vv is the difference between "one line" and "the whole gossip".

also note that for ftp.kulnet.kuleuven.ac.be and ftp.de.debian.org in this case, nothing got through at all. that indicates that either the host doesn't exist, or it is down. either way, not it. 😭


next up:

# netselect -vv http.us.debian.org

this is the output:

204.152.191.39               300 ms  17 hops   90% ok ( 9/10) [  899]
35.9.37.225                  9999 ms  30 hops    0% ok
64.50.233.100                9999 ms  30 hops    0% ok
128.30.2.36                  183 ms  15 hops   90% ok ( 9/10) [  510]
149.20.20.135                226 ms  18 hops   90% ok ( 9/10) [  702]
 510 128.30.2.36

in this case, since the single name has multiple DNS addresses, all of the servers will be tested independently and the fastest server will be provided. slay ✨


so if you noticed the above output, you'll see that the time for some hosts is 9999 ms. this is typically an indication of remote hosts blocking the UDP probes netselect relies on. to prevent this issue you can use ICMP tests. for example, repeating the above test using ICMP, that is:

# netselect -I -vv http.us.debian.org

yields the following output:

204.152.191.39               291 ms  17 hops  100% ok (10/10) [  785]
35.9.37.225                  180 ms  19 hops   66% ok ( 2/ 3) [  783]
64.50.233.100                140 ms  12 hops  100% ok (10/10) [  308]
128.30.2.36                  182 ms  15 hops  100% ok (10/10) [  455]
149.20.20.135                227 ms  18 hops  100% ok (10/10) [  635]
 308 64.50.233.100

in this last example the selected server will change, since β€” actually β€” the fastest server is one that also actively blocks UDP probes. plot twist πŸ“


you can also use the tag feature, based on postpending the server name with itself, so the result includes both the fastest IP address and the original server name. for example, running a query with tags such as this one:

# netselect -I -vv http.us.debian.org:http.us.debian.org

will yield output similar to:

35.9.37.225:http.us.debian.org        9999 ms  30 hops    0% ok
64.50.233.100:http.us.debian.org      9999 ms  30 hops    0% ok
64.50.236.52:http.us.debian.org       9999 ms  30 hops    0% ok
128.30.2.36:http.us.debian.org         189 ms  14 hops   90% ok ( 9/10) [  504]
199.6.12.70:http.us.debian.org         286 ms  17 hops   90% ok ( 9/10) [  858]
 504 128.30.2.36:http.us.debian.org

or you can use the -D option to force netselect to print out only DNS names. for example:

# netselect -I -vv -D ftp.us.debian.org ftp.ru.debian.org

will yield output similar to:

128.30.2.36                  186 ms  14 hops  100% ok (10/10) [  446]
199.6.12.70                  294 ms  17 hops   87% ok ( 7/ 8) [  907]
35.9.37.225                  177 ms  19 hops   66% ok ( 2/ 3) [  768]
64.50.233.100                141 ms  12 hops  100% ok (10/10) [  310]
64.50.236.52                 162 ms  13 hops  100% ok (10/10) [  372]
ftp.ru.debian.org            112 ms  18 hops  100% ok (10/10) [  313]
 310 ftp.us.debian.org

as you can see here, netselect will select a DNS name (in the example 'ftp.us.debian.org') which is associated with multiple IP addresses over other servers, as long as there is one server in the pool faster than the others.

however β€” and this is the important bit, bestie β€” using the DNS name for a server configuration might lead to actually slower throughput if, on average, the different IP addresses are not as responsive. in the above example, 'ftp.ru.debian.org' is second on the list and might be a better option (again, on average) than 'ftp.us.debian.org'. so like, read the room before you commit. πŸ™ˆ


πŸ‘‘ OPTIONS πŸ‘‘

  • -v β€” Verbose mode. Displays nameserver resolution messages to stderr. You probably want this so that you don't get bored waiting for a hundred name resolutions to finish. lowkey essential honestly.
  • -vv β€” Very verbose mode. Displays nameserver resolution and statistics (not just scores) to STDERR and STDOUT.
  • -vvv β€” Very very verbose mode. Everything -vv prints, plus it print every packet received as it happens. Good for debugging or trying to figure out how it works.
  • -vvvv β€” Very very very verbose mode. Everything -vvv prints, plus a trace of all packets sent. maximum yapping, zero secrets πŸ’…
  • -m HOPS β€” Maximum TTL (time to live). Don't accept hosts that are further than HOPS away.
  • -s SERVERS β€” Print this many "top-scoring" SERVERS at the end of the list. If SERVERS is 0, then this disables printing of high scores.
  • -t PACKETS β€” Make sure at least 50% of the hosts get tested with this many PACKETS. The more packets you use, the more accurate are the results... and the longer it takes to run. The default is 10, which is usually okay.
  • -I β€” Use ICMP instead of UDP probes. On some occasions (e.g. firewalled hosts) UDP probes like those used in traceroute will get filtered out and hosts might be perceived as dead. Using this option will make netselect use ICMP probes instead. the fixer ✨
  • -D β€” netselect provides the IP address of the servers that are tested if the name resolves to more than one address (i.e. the remote end is using DNS round-robin). This makes it easier to spot which is the fastest server of a pool but might not be useful if you wish to configure a system daemon with the DNS name or if the remote service does not accept calls to its IP address (as some HTTP servers do). This option forces netselect to present the final server list using the original DNS name instead of the IP address if the DNS name resolves to more than one IP address.

🧚 SEE ALSO 🧚

ping(8), traceroute(8), netselect-apt(1).


πŸ’œ AUTHOR πŸ’œ

Avery Pennarun <apenwarr@gmail.com>


and that's the whole page, bestie 🫢 go forth and let netselect pick your fastest server, you absolute icon πŸ‘‘

this was the DEBIAN edition of the NETSELECT(1) manual page, dated March 14, 2004 β€” yes it's vintage, yes it still eats πŸ’…

πŸ“¦ where this page comes from