Traceroute and MTR are root tools by tradition: they use raw sockets, so you run them with sudo or install them setuid. macOS has a second way in, an ICMP socket any user can open, and it is how Netutilus traces a route from inside the Mac App Store sandbox. This post shows that socket from Terminal, the one sandbox entitlement that decides whether an app can read its replies, and the limits that remain.

Commands tested on macOS 27.0.1 on 2026-10-20. Addresses and names in the output are replaced.

The problem: traceroute and mtr want root

A traceroute sends packets with a rising TTL (time to live). The router that drops a packet when its TTL runs out sends back an ICMP “time exceeded” message, and that reply names the hop. The classic way to send those probes and read the replies is a raw socket, and a normal user can’t open one.

macOS’s own traceroute gets round this with the setuid bit. Apple’s source says it plainly, “This program must be run by root or be setuid”, and the binary on this Mac is owned by root with the s bit set:

$ ls -l /usr/sbin/traceroute /sbin/ping
-r-xr-xr-x  1 root  wheel  268560 Sep 24 10:10 /sbin/ping
-r-sr-xr-x  1 root  wheel  269936 Sep 24 10:10 /usr/sbin/traceroute

So traceroute works without sudo on a Mac. mtr from Homebrew does not. Its formula warns: “mtr requires root privileges so you will need to run sudo mtr.” mtr’s SECURITY file explains why: mtr starts a helper, mtr-packet, which “requires extra privileges to send custom packets”. The current code opens raw sockets and falls back to unprivileged ones only in builds for Linux. Anywhere else, without privileges, it stops with “Failure to open IPv4 sockets”. Older versions, such as 0.87, printed “mtr: unable to get raw sockets.”

An App Store app has neither option. Netutilus runs as you, inside the App Sandbox, with no helper tool. And a normal user can’t open a raw ICMP socket, even outside any sandbox:

$ python3 -c 'import socket; socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)'
...
PermissionError: [Errno 1] Operation not permitted

Unprivileged ICMP sockets on macOS

The way out is in the icmp(4) manual page, under “Non-privileged ICMP”: “ICMP sockets can be opened with the SOCK_DGRAM socket type without requiring root privileges.”

socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)

The same page sets the rules for this socket:

Rule From icmp(4)
What you can send Only ICMP_ECHO, ICMP_TSTAMP or ICMP_MASKREQ, with code 0
Socket options IP_TTL is on the list, along with IP_TOS, IP_HDRINCL and others
What you receive Incoming packets arrive “with the IP header and options intact”
What it is for “to receive time exceeded messages for traceroute”

ping already uses it. In Apple’s ping.c, a user other than root gets socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) and root gets a raw socket. That is why /sbin/ping above has no setuid bit and still works. You can watch it receive a time-exceeded reply by limiting the TTL to 1 with -m 1:

$ ping -c 2 -m 1 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
92 bytes from 192.168.1.1: Time to live exceeded
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
 4  5  00 5400 c77f   0 0000  01  01 c156 192.168.1.23  1.1.1.1

Request timeout for icmp_seq 0
...
2 packets transmitted, 0 packets received, 100.0% packet loss

The router at hop 1 answered. That is one row of a traceroute, sent and received without root.

TTL, the replies, and the sandbox entitlement that matters

A whole traceroute fits in a short script. This one opens a datagram ICMP socket per TTL, sets IP_TTL, sends an echo request and waits two seconds for the reply that carries its sequence number. A router answers with type 11, time exceeded, and quotes the start of our packet, so the sequence number sits inside the quote. The destination answers with type 0, echo reply. Tested without sudo with Python 3.15 and with the system’s /usr/bin/python3 (3.9.6):

import socket, struct, sys, time

def checksum(b):
    s = sum(struct.unpack(f"!{len(b)//2}H", b))
    s = (s >> 16) + (s & 0xFFFF)
    return ~(s + (s >> 16)) & 0xFFFF

dest = sys.argv[1]
for ttl in range(1, 31):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_ICMP)
    s.setsockopt(socket.IPPROTO_IP, socket.IP_TTL, ttl)
    s.settimeout(2)
    seq = 0x3000 + ttl
    hdr = struct.pack("!BBHHH", 8, 0, 0, 0, seq) + b"ttl-probe!"   # ICMP echo
    pkt = hdr[:2] + struct.pack("!H", checksum(hdr)) + hdr[4:]
    t0 = time.monotonic()
    s.sendto(pkt, (dest, 0))
    line = f"{ttl:2}  *"
    try:
        while True:
            buf, (src, _) = s.recvfrom(1500)
            ip = (buf[0] & 0x0F) * 4               # the IP header comes with it
            kind = buf[ip]
            if kind == 0:                          # echo reply: the destination
                got = struct.unpack("!H", buf[ip+6:ip+8])[0]
            elif kind == 11:                       # time exceeded: a router
                q = ip + 8 + (buf[ip+8] & 0x0F) * 4  # our datagram, quoted
                got = struct.unpack("!H", buf[q+6:q+8])[0]
            else:
                continue
            if got == seq:
                ms = (time.monotonic() - t0) * 1000
                line = f"{ttl:2}  {src:15}  type {kind:2}  {ms:.3f} ms"
                break
    except socket.timeout:
        pass
    print(line)
    s.close()
    if line.endswith("ms") and kind == 0:
        break
$ python3 ttl_probe.py 1.1.1.1
 1  192.168.1.1      type 11  3.198 ms
 2  10.20.0.1        type 11  3.587 ms
 3  172.16.10.10     type 11  6.844 ms
 4  172.16.10.9      type 11  4.282 ms
 5  *
 6  1.1.1.1          type  0  15.207 ms

Hop 5 is a router that doesn’t answer probes, which is common. The kernel enforces the rules from the man page: sending an echo reply (type 0) or a destination-unreachable (type 3) on this socket fails with EINVAL.

Inside the App Sandbox

Open the same socket in a sandboxed app with only the outgoing-connections entitlement, and it half works. Netutilus’s engineering notes record the test: two ad-hoc-signed sandboxed builds that differ only in com.apple.security.network.server. The one without it gets “socket ok → sendto ok → recvfrom: Operation not permitted”. The probes go out, and the app never sees an answer.

Apple’s documentation for the network entitlements describes the same split for UDP: “the network entitlements restrict both initiation and data flow. For example, an app with only the client entitlement enabled can send, but not receive, data.” An echo reply or a time-exceeded message arrives unasked, not on a connection the app opened, and the sandbox treats reading it as an incoming operation.

The sandbox rules on this Mac show the mapping. In /System/Library/Sandbox/Profiles/, the client entitlement turns on (allow network-outbound (remote ip)), and the server entitlement turns on (allow network-inbound (local ip)). You can reproduce the failure with sandbox-exec and a one-line profile that denies inbound network access. sandbox-exec is deprecated and is not the App Sandbox, but it shows the same rule at work. sbtest.py opens the same datagram ICMP socket, sends one echo request to the router and waits for the reply:

$ sandbox-exec -p '(version 1)(allow default)' python3 sbtest.py 192.168.1.1
socket: ok
sendto: ok
recvfrom: ok, 40 bytes, icmp type 0

$ sandbox-exec -p '(version 1)(allow default)(deny network-inbound)' python3 sbtest.py 192.168.1.1
socket: ok
sendto: ok
recvfrom: Operation not permitted

So Netutilus ships with both network entitlements, even though it listens on no port:

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>

In Xcode the second one is the “Incoming Connections (Server)” checkbox, which looks odd in an app that listens on no port. It was once deleted from the project as apparently unused, and restored eleven minutes later. Without it, Traceroute, MTR, the Ping tool’s ICMP mode and the Uptime Monitor’s ICMP check all still send, and never see a reply.

What we still can’t read

The datagram socket gets an App Store app a real ICMP traceroute. It does not get everything a root tool has.

  • ICMP echo only. The socket sends only echo, timestamp and address-mask requests, and Netutilus’s Traceroute and MTR send echo requests. Neither has a TCP or UDP mode, so neither can run the equivalent of mtr -T to trace to a web server’s port. Trippy’s documentation says its unprivileged mode on macOS covers ICMP, UDP and TCP tracing, so macOS allows more than Netutilus uses today, at least outside the App Sandbox. If you need a TCP trace now, use Trippy or sudo mtr -T.
  • IPv4 only. Netutilus resolves hosts for its ICMP tools to IPv4 addresses and rejects an IPv6 address with its own message. For an IPv6 path, use traceroute6 or mtr -6.
  • Your own network needs another permission. With Local Network access off for Netutilus, macOS refuses a probe to an address on your LAN at the send. Turn it on in System Settings › Privacy & Security › Local Network.

Every reply goes to every ICMP socket

In our test, a second datagram ICMP socket in the same process, which had sent nothing, received the echo reply meant for the first one:

socket B (sent nothing) received type 0 seq 0x0202 from 192.168.1.1

So an app can’t trust a reply because it arrived on its socket. Netutilus matches every reply by sequence number. Traceroute adds a random offset per run and checks that the quoted packet was sent to the host being traced. The Ping tool’s ICMP mode also checks that the reply came from the target. Without that, two runs at once could take each other’s answers.

MTR on top: per-hop loss without sudo

MTR is the same probe, repeated. Netutilus’s MTR runs one probe loop per TTL, up to 30 hops by default. Each loop sends an echo request with its TTL and waits up to 1, 2 or 3 seconds for the reply, 2 by default. It sends the next one an interval after the last one left: 1, 1.5, 2 or 5 seconds, 1.5 by default. The sequence number carries the TTL in its high byte and a round counter in its low byte, so a reply that reaches the wrong loop is ignored.

Two details shaped the design:

  1. Loops past the destination go quiet. Every reply reaches every ICMP socket in the app. On a six-hop path, the loops for TTL 7 to 30 would only reach the destination again, and each of their replies would wake all 30 sockets. Those loops pause, and probe again after the destination misses four probes, or when its TTL starts answering as a router, which means the path got longer.
  2. Loss is judged at the destination. Routers answer probes addressed to themselves at low priority. Loss at one hop that does not carry on to the last hop is that router limiting its replies, not lost traffic. Netutilus’s MTR summary applies that rule, and its outage log records only runs of two or more lost probes in a row to the destination.

Each hop gets the usual columns, Loss%, Sent, Last, Avg, Best, Worst and Stdev, and every run is recorded for the History tab. None of it needs sudo, Homebrew or a helper. What packet loss at a hop means covers reading the result.

Try it

From Terminal, with no install:

  • traceroute example.com: the built-in one is setuid, so no sudo.
  • ping -c 1 -m 1 example.com: one time-exceeded reply from your router through the unprivileged socket.

With Python 3, the script above shows the raw replies. For an MTR without sudo in Terminal, Trippy runs on macOS with trip example.com --unprivileged. Homebrew’s mtr needs sudo mtr.

In Netutilus, Traceroute is free and MTR is part of Netutilus Pro. Both run on this socket inside the App Sandbox. Hops and TTL explains how a route is found, and ICMP and TCP ping explains why some hosts ignore ICMP.

Note: Netutilus is made by Poteam, who publish this site.