0

I've looked through help using help netstat and can't see a way to just show tun interfaces (or sockets).

I found one netstat option that isn't listed in the help, netstat -u which only shows "Active LOCAL (UNIX) domain sockets".

I can grep the results of that command for ".sock" but would like to only one command.

I am wondering if there are any more "unlisted" netstat options for the mac version of netstat.

1 Answer 1

1

The man-page for netstat lists these options:

A, a, b, c, d, f, g, I, i, L, l, ll, lll, m, n, p, q, r, R, s, S, v, W, w, x and z.

The source code for netstat lists these options:

A, a, b, c, d, F, f, g, I, i, L, l, ll, lll, m, n, P, p, Q, q, r, R, s, S, t, u, v, W, w, x and z

So the unlisted netstat options are: F, P, Q, t and u.

You have already discovered u, which means to list only AF_UNIX sockets.

The rest have this meaning:

  • F: Show interface forwarded packets
  • P: Show packet priority statistics
  • Q: Opportunistic polling stats display
  • t: Show interface watchdog timers

This means that there's no "secret" option that will make netstat output what you desire. You can either use a different (probably custom made) tool, or parse its output with tools like grep.

For example you could dig information about utun interfaces out of the System Configuration daemon by running a command like this:

echo list "State:/Network/Interface/utun.*" | scutil

The scutil commands also allows you to watch for changes, so that you can run the command in the background and report whenever an interface is created or destroyed.

10
  • Where would a user find the source code for BSD netstat? I think it's BSD... Any idea on how to show only "utun" interfaces using CLI on Mac?
    – John
    Commented Apr 29, 2022 at 21:35
  • I'm still writing on the answer - hold on.
    – jksoegaard
    Commented Apr 29, 2022 at 21:35
  • I have completed the answer for now. There's no secret "utun only" option. Can you elaborate on why you need this - perhaps there's an easier way to solve your problem.
    – jksoegaard
    Commented Apr 29, 2022 at 21:41
  • Regarding the source code: It's not really "the BSD netstat" - yes, the original program came from BSD and was forked from there at the time. But that was 1993/1994 - a long time has passed. You need to look for Apple's netstat instead. It's available on Apple's open source page (opensource.apple.com).
    – jksoegaard
    Commented Apr 29, 2022 at 21:45
  • When I connect to my VPN provider. They create a utun interface that creates another utun interface for me to use. I am looking for a way to “get” that utun info
    – John
    Commented Apr 29, 2022 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .