find your network settings: mac and pc

2021-06-23

 | 

~4 min read

 | 

793 words

It can be really useful to see what your network settings look like. How do you do that though?

Depending on your platform, I’ve found a few different ways to do it.

Mac Solutions

On Unix, there’s ipconfig and ifconfig. To get just your IP address, you can do:

% ipconfig getifaddr en0
192.168.86.47

Meanwhile, if you forget that it’s en0 that you care about, you can get a full dump of your entire network settings with \sbin\ifconfig which will provide a full dump of your network interface parameters.1

% \sbin\ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether ac:de:48:00:11:22
        inet6 fe80::aede:48ff:fe00:1122%en5 prefixlen 64 scopeid 0x4
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect (100baseTX <full-duplex>)
        status: active
ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether a6:83:e7:e2:7f:36
        media: autoselect
        status: inactive
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether a4:83:e7:e2:7f:36
        inet6 fe80::1470:1d35:ba28:e8c5%en0 prefixlen 64 secured scopeid 0x6
        inet 192.168.86.47 netmask 0xffffff00 broadcast 192.168.86.255
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=460<TSO4,TSO6,CHANNEL_IO>
        ether 82:4f:e8:a8:84:05
        media: autoselect <full-duplex>
        status: inactive
en4: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=460<TSO4,TSO6,CHANNEL_IO>
        ether 82:4f:e8:a8:84:04
        media: autoselect <full-duplex>
        status: inactive
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=460<TSO4,TSO6,CHANNEL_IO>
        ether 82:4f:e8:a8:84:01
        media: autoselect <full-duplex>
        status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=460<TSO4,TSO6,CHANNEL_IO>
        ether 82:4f:e8:a8:84:00
        media: autoselect <full-duplex>
        status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=63<RXCSUM,TXCSUM,TSO4,TSO6>
        ether 82:4f:e8:a8:84:01
        Configuration:
                id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
                maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
                root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
                ipfilter disabled flags 0x0
        member: en1 flags=3<LEARNING,DISCOVER>
                ifmaxaddr 0 port 9 priority 0 path cost 0
        member: en2 flags=3<LEARNING,DISCOVER>
                ifmaxaddr 0 port 10 priority 0 path cost 0
        member: en3 flags=3<LEARNING,DISCOVER>
                ifmaxaddr 0 port 7 priority 0 path cost 0
        member: en4 flags=3<LEARNING,DISCOVER>
                ifmaxaddr 0 port 8 priority 0 path cost 0
        nd6 options=201<PERFORMNUD,DAD>
        media: <unknown type>
        status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether 76:ca:a4:8f:d6:52
        inet6 fe80::74ca:a4ff:fe8f:d652%awdl0 prefixlen 64 scopeid 0xc
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether 76:ca:a4:8f:d6:52
        inet6 fe80::74ca:a4ff:fe8f:d652%llw0 prefixlen 64 scopeid 0xd
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
        inet6 fe80::8ed5:77a:4bab:8ddf%utun0 prefixlen 64 scopeid 0xe
        nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
        inet6 fe80::9cac:9452:5271:8a01%utun1 prefixlen 64 scopeid 0xf
        nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
        inet6 fe80::497b:8389:2935:21e2%utun2 prefixlen 64 scopeid 0x10
        nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
        inet6 fe80::e7a7:c4e9:d9ef:115d%utun3 prefixlen 64 scopeid 0x11
        nd6 options=201<PERFORMNUD,DAD>

This can be a rather overwhelming list, but StackOverflow helps explain:

  • en0 was originally the first ethernet network interface, though it now frequently refers to a wireless network. In the case above, 192.168.86.47 was my local IP when I ran the command.
  • lo0 is a loopback, or more commonly known as an internal IP address / localhost.

There are a bunch of others (obviously), but to date, I’ve not needed to know any of them.

Windows Approach

On Windows, I’ve found at least one way to do it and it’s simpler - no need to give a full path to a utility or remember which network interface you care about.

    PS C:\> ipconfig
Windows IP Configuration

Ethernet adapter Ethernet 2:
    Media State . . . . . . . . . . . : Media disconnected
    Connection-specific DNS Suffix  . :
Ethernet adapter Ethernet:
    Connection-specific DNS Suffix  . : localdomain
    IPv6 Address. . . . . . . . . . . : fdb2:2c26:f4e4:0:a564:bfc:a760:f91
    Temporary IPv6 Address. . . . . . : fdb2:2c26:f4e4:0:bd0c:8b44:6f5d:5690
    Link-local IPv6 Address . . . . . : fe80::a564:bfc:a760:f91%4
    IPv4 Address. . . . . . . . . . . : 10.211.55.3
    Subnet Mask . . . . . . . . . . . : 255.255.255.0
    Default Gateway . . . . . . . . . : 10.211.55.1

Conclusion

It’s not surprising that the way to find your IP address would differ between platforms, but for summary, if what you care about is just your IP address, you can use ipconfig getifaddr en0 on a Mac or ipconfig on Windows. For more robust information on the Mac, use the sbin utility: /sbin/ifconfig.

Footnotes

  • 1 On MacOS, sbin is not part of $PATH by default. While it’s easy enough to add it to $PATH, it seems that it’s most appropriate only for root users. From the Linux Information Project on sbin:

    /sbin is similar to /bin, which contains executable programs needed to boot (i.e., start) the system, except that /sbin’s programs are normally executed only by the root user. Thus, /sbin is by default not in the PATH environmental variable of ordinary users, but it is for the root account.


Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!