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 your user.

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:
Code language: Bash (bash)

Now let’s navigate to the temporary directory and download the sources from

cd temp curl -OL curl -OL curl -OL curl -OL
Code language: Bash (bash)

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

tar xfz autoconf-2.69.tar.gz cd autoconf-2.69 ./configure –prefix=/usr/local make make install autoconf-2.69 % cd ..
Code language: Bash (bash)
tar xfz automake-1.16.tar.gz cd automake-1.16 ./configure –prefix=/usr/local make make install cd ..
Code language: Bash (bash)
tar xfz libtool-2.4.6.tar.gz cd libtool-2.4.6 ./configure –prefix=/usr/local make make install cd ..
Code language: Bash (bash)
tar xfz m4-1.4.18.tar.gz cd m4-1.4.18 ./configure –prefix=/usr/local make make install cd ..
Code language: Bash (bash)

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 tar xfz mtr-0.92.tar.gz cd mtr-0.92 ./configure –prefix=/usr/local make make install cd
Code language: Bash (bash)

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
Code language: Bash (bash)
Code language: Bash (bash)

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
Code language: Bash (bash)
# Alias Catalog alias mtr=’sudo /usr/local/sbin/mtr’ # Env export PATH=”$PATH:/usr/local/sbin”
Code language: Bash (bash)

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. 0.0% 20 56.9 57.6 56.4 59.7 0.9 3. 0.0% 20 60.1 56.8 56.0 60.1 0.9 4. 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. 0.0% 19 66.9 65.9 65.1 68.2 0.9
Code language: Bash (bash)

Leave a Reply

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

Related Posts