MTR, or “My Traceroute” (originally named Matt’s traceroute after its original creator Matt Kimball) is an amazing network diagnose tool that combines the functionality of both ‘ping’ and ‘traceroute’ into one single program. It determines the route and address of each hop between the source and destination, and sends a sequence of ICMP ECHO requests to each hop, in order to measure the quality of the connection at each point.

Most of us on the Mac are already familiar with the Homebrew package manager, a free and open-source software manager that makes it easier to install and configure several applications from the Terminal on your Mac. However, with the growth of Docker and the advantages of running apps in a containerised environment, with most recent versions of Apache, PHP and even php-fpm being shipped natively with Catalina, I have decided to ditch Homebrew and all of its never ending dependencies, as I won’t be needing concurrent PHP versions (and if I do, I can just spin up a container with whatever version of php I want and point the document folder to where my project sits), I won’t be running MariaDB or PostgreSQL as they’re running in containers as well.

So, for the sake of keeping clutter away from the Mac and while moving away from brew I noticed at least one program I could use locally – mtr – but since it was previously installed with Homebrew, I’d have to build it from source.

Apple’s macOS has very restrict policies regarding where user software can or cannot be. To keep our system lean and well organised, we will be using the recommended path for local software installs, /usr/local

Before building and compiling mtr, we will need to install a few missing components. These will be autoconf, automake, libtools and m4 processor. If you haven’t yet, you will also need to install Xcode (available on the App Store) agree to the terms and let it install any missing components it requires.

Next, let’s start by opening the Terminal and navigate to the /usr/local folder. We will then create a new temporary folder and set the appropriate ownership so we don’t get errors ahead. The path /usr/local belongs to the root user, so sudo is required to create new folders or files inside of it, so I’ll be creating the necessary directories that don’t exist yet and set the appropriate ownership. Don’t forget to replace the user ‘user1’ with yours.

Check if /usr/local/bin is on your PATH, by issuing the command echo $PATH.

cd /usr/local
sudo mkdir include sbin temp && sudo chown user1:admin include sbin temp
Password:

Now let’s navigate to the temporary directory and download the sources from ftp.gnu.org

cd temp
curl -OL https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
curl -OL https://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz
curl -OL https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz
curl -OL https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz

Next lets uncompress the archives and start building and compiling in the following order.

Autoconf
tar xfz autoconf-2.69.tar.gz
cd autoconf-2.69
./configure –prefix=/usr/local
make
make install
autoconf-2.69 % cd ..
Automake
tar xfz automake-1.16.tar.gz
cd automake-1.16
./configure –prefix=/usr/local
make
make install
cd ..
Libtool
tar xfz libtool-2.4.6.tar.gz
cd libtool-2.4.6
./configure –prefix=/usr/local
make
make install
cd ..
M4
tar xfz m4-1.4.18.tar.gz
cd m4-1.4.18
./configure –prefix=/usr/local
make
make install
cd ..

The only issue I’ve come up in this process are path permissions. If all is ok, this is a very straightforward process.

Don’t use sudo. If you do, files will be owned by root, and will break as you won’t be able to build unless using sudo.

Now finally we just need to do the same with mtr, the same options and process, its very straightforward.

curl -OL https://www.bitwizard.nl/mtr/files/mtr-0.92.tar.gz
tar xfz mtr-0.92.tar.gz
cd mtr-0.92
./configure –prefix=/usr/local
make
make install
cd

And voilá, mtr is installed.

Finally, depending on your environment configuration, /usr/local/sbin may or may not be set on your PATH. To check if it is, you can issue the following command:

echo $PATH
Output:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

The PATH configuration varies from user to user and the software each user has installed. These should be the basics.

As /usr/local/sbin isn’t set, we have two options: we may add this path to the environment variable, by editing .zshrc or .bashrc and adding the command export to add it, we can create an alias pointing directly at the executable, or even both (that I did so I wouldn’t have to be writing sudo each time, as mtr does require to be ran as sudo).

cd
vim .zshrc
Content
# Alias Catalog
alias mtr=’sudo /usr/local/sbin/mtr’

# Env
export PATH=”$PATH:/usr/local/sbin”

And now we can freely invoke mtr to diagnose network connections. Your password will be required.

My traceroute [v0.91.1-4c982]
macOS.local (—-:—-:—-:—-:—-:—-:—-:—-) 2019-11-13T10:39:40+0000
Keys: Help Display mode Restart statistics Order of fields quit
–                                       Packets             Pings
Host                                  Loss%   Snt   Last   Avg   Best   Wrst   StDev
1. fw.local                            0.0%    20    1.2   1.2    1.1    1.5     0.1
2. tunnel.tserv1.lis1.ipv6.he.net      0.0%    20   56.9  57.6   56.4   59.7     0.9
3. 10ge11-20.core1.lis1.he.net         0.0%    20   60.1  56.8   56.0   60.1     0.9
4. google.as15169.ipv6.gigapix.pt      0.0%    20   73.8  58.2   56.3   73.8     3.9
5. 2001:4860:0:25::6                   0.0%    20   87.5  68.2   57.4   92.2    10.1
6. 2001:4860::9:4001:2750              0.0%    20   65.0  68.4   64.6   94.3     7.9
7. 2001:4860::9:4001:2751              0.0%    20   65.7  66.7   65.7   68.1     0.7
8. 2001:4860:0:1::f15                 36.8%    19   67.1  67.4   66.2   73.0     1.8
9. mad07s10-in-x0e.1e100.net           0.0%    19   66.9  65.9   65.1   68.2     0.9
Spread the love

Leave a Reply

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

Related Posts