There is a port under ports-mgmt called fastest_sites. This the MASTER_SITE definitions depending on the round-trip time for the tcp connections. The results are sorted by fastest response time and in a format suitable for Makefile.

# cd /usr/ports/ports-mgmt/fastest_sites

# make install

Now let’s generate the sorted list of master sites:

# fastest_sites > /usr/local/etc/ports_sites.conf &

This step may take some time as quite a number of sites have to be checked. In the meantime you can add the following line to /etc/make.conf:

.include "/usr/local/etc/ports_sites.conf"

From: Originally published by the writer of this python script on