While macOS offers an easy-to-use menu for your network settings in the System Preferences menu, the Terminal app is where you need to be if you want to quickly lookup or test information about your network configuration. You can use it to find your IP address, find your location, check your system firewall, and more.

Your network settings can be accessed using some common terminal commands that, for the most part, require very little configuration to use. We still recommend you use the System Preferences app for configuration (unless you’re happy using the terminal), but identifying your Mac terminal network settings is easy.

Table of Contents
    How to Use Mac Terminal to Identify Network Settings

    Using networksetup

    The networksetup tool offers an enormous amount of information on your current Mac network configuration. You can use it to find your computer name, IP address, current WiFi network, and more. As the name suggests, you can also use it to change settings, but we’d still recommend using System Preferences to do this.

    You can view a full list of potential Mac terminal network commands using the networksetup tool by typing networksetup -help at the terminal. This will display the help list, with various examples of how to use the tool to view and change different network settings.

    Networksetup in terminal window

    Examples of networksetup commands you can use to view network information include:

    • To view your Mac computer name: networksetup -getcomputername.
    • To list all Mac network connections: networksetup -listallhardwareports
    • To display the current, connected WiFi network: networksetup -getairportname deviceid. Replace deviceid with a device ID from the networksetup -listallhardwareports command.

    Using ipconfig

    The ipconfig tool is common to Windows and macOS computers but, unlike the Windows version, it isn’t the most useful tool for changing network settings. Where it can be useful, however, is listing information on your current network configuration.

    Typing ipconfig at the terminal will list all available commands, but these include:

    Ipconfig command in terminal window
    • To view your current network IP address: ipconfig getifaddr deviceid. Replace deviceid with the correct network device id (eg. en0). Type networksetup -listallhardwareports if you don’t know this.
    •  To view your current network DNS server: ipconfig getoption deviceid domain_name_server (replacing deviceid with your network device id).

    Using ifconfig

    The ifconfig command is another network configuration tool available to users on macOS and Linux PCs. Unlike ipconfig, however, ifconfig is a much more powerful tool for viewing and modifying your network settings.

    Ifconfig command in terminal

    However, you only need to type ifconfig at the terminal to view a detailed list of information for all of the network devices connected or integrated into your Mac. That includes IP and MAC addresses, current device status, and more.

    You can view specific information by listing the device id (for example, ifconfig en0) instead.

    Using ping

    While you can’t use it to view any network information, you can use the ping command to test whether or not you can make contact with another network device. It could be a device on your network (for instance, your network router) or a website domain or internet IP address to test your internet connectivity.

    You’ll want to use ping as a troubleshooting tool whenever your device seems to be having issues with connecting to another device on your local network, or a device or website on the internet. It will show the time taken for information to be sent and returned and will run continuously until you decide to end it.

    Ping command in terminal

    To use it, type ping address, replacing address with an IP address or domain name. A common target for testing is google.com—if you can’t hit Google, you probably don’t have internet connectivity.

    Likewise, ping 192.168.1.1 will test the IP address for many local network routers (192.168.1.1).

    Using netstat

    The netstat tool lists information on your current incoming and outgoing network connections. Any connections made to your Mac can be listed using this tool. Windows and Linux PCs also use netstat, but there are some differences, with different available flags to Mac users.

    There are several ways you can use netstat to view current network settings or connections. These include:

    Netstat tool in terminal window
    • For a current list of all active internet connections: netstat
    • To view connection data for an interface: netstat -l deviceid, replacing deviceid with your network interface name (eg. netstat -l en0).
    • To view the IP routing table: netstat -nr or netstat -r
    • To show all network statistics: netstat -s and netstat -i

    For more information on how to use the netstat command and to help decipher some of the complex technical terminologies, type man netstat to view and read through the included netstat man page.

    Using lsof

    You can use the lsof command as a way to view any running processes on your Mac that have active network connections. This replaces similar functionality that you’d find with the netstat command on Windows or Linux PCs.

    Lsof command in terminal

    There are several ways you can use the lsof Mac terminal command to view network data. These include:

    • To view all open network connections: lsof -i
    • To view what software is using what ports: lsof -n -i4TCP

    For more information, type man lsof to view the man page for the lsof command.

    Using arp

    If you want to view a list of all active devices on a local network, you could use the arp tool. This will list the IP and MAC addresses for any devices that your Mac has detected on your network, based on the ARP (Address Resolution Protocol) broadcasts those devices have made.

    Typing arp -a at the terminal will provide you with a list of these devices.

    Arp command in terminal

    You could then combine the information found here with other commands like ping to determine whether or not those devices are still active and can be communicated with from your Mac.

    Configuring Your Mac Network Settings

    With your Mac terminal network settings in view using these tools, you can identify the settings you may prefer to (or need to) change. For instance, you may need to spoof a MAC address on your Mac to bypass MAC address filtering on a guest WiFi network.

    It can also help you identify problems, especially if your Mac drops its WiFi connection regularly. If your Mac is having issues, apps like OnyX for Mac can help you get back up and running quickly.