Mac OSX: mtr: unable to get raw sockets

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, March 24, 2016

Follow me on Twitter as @mattiasgeniar

So you went and installed mtr via the Brew package manager, only to find it doesn’t really work? Bummer. Good thing there’s a fix.

$ mtr ma.ttias.be
host: ma.ttias.be
mtr: unable to get raw sockets.

But the sudo variant does work:

$ sudo mtr ma.ttias.be
  1.|-- 10.200.200.200             0.0%     1   14.4  14.4  14.4  14.4   0.0
  2.|-- 10.0.1.1                   0.0%     1   17.7  17.7  17.7  17.7   0.0
  3.|-- ge-0-0-24-605.rtr1.ant1.n  0.0%     1   14.7  14.7  14.7  14.7   0.0
  4.|-- ge-0-0-20-2.csw01.ocs.ant  0.0%     1   15.5  15.5  15.5  15.5   0.0
  5.|-- ma.ttias.be                0.0%     1   15.5  15.5  15.5  15.5   0.0

Having to sudo every time is a bit of a pain, so we can use the magic setuid bit that allows us to execute mtr without additional hassle.

$ which mtr
/usr/local/sbin/mtr

$ chmod 4755 /usr/local/sbin/mtr

$ sudo chown root /usr/local/sbin/mtr

Now, next time you execute mtr, it’ll just work. It’s like magic.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.