How to scan local area network with Terminal on macOS
Terminal on macOS is a handy tool but few people use it. This article will guide you to use Terminal in macOS to scan local area network for troubleshooting and maintenance. The macOS terminal works a bit differently than the Linux utility with some other flags. So don't assume all Linux Terminal skills will work correctly on macOS.
- How to determine the device IP address on the local network
- Instructions for installing LAN with systems using multiple operating systems
- Share a folder on local network for new users
Scan the open ports of local area network with nmap
Nmap is a command line port scanner on macOS but you need to install it first to use it.
Install nmap with Homebrew
If Homebrew is already installed, run the following command to download and install nmap and the required dependencies.
- Instructions for installing the software using Homebrew on macOS X
brew install nmap
Scanning with nmap
The nmap is built to scan the hostname or network address provided and return a list of open ports. nmap stands for network mapper but performs a role as a port mapper (port mapper).
The simplest way to run nmap is with the IP address or the specified IP address range as the target. Run the following command with the appropriate IP address to scan your local network. Here the command scans nmap's test server at scanme.org.
nmap 74.207.244.221 nmap scanme.org
To scan open ports on a range of IP addresses, use a forward slash.
nmap 192.181.0.0/24
To find the IP address for routers and other devices on the network, run arp
or ipconfig
.
sudo nmap -A scanme.org
Use -A
flag to force nmap to scan faster and stronger, return more information and clearly reveal your presence in server logs. -A
flag needs to run with sudo.
sudo nmap -O scanme.org
The above command scans the specified IP address for the operating system ( -O
).
If you want to run nmap 'stealth' a bit, use the -sS
flag:
sudo nmap -sS scanme.org
The above command scans the first half, sends a TCP SYN packet to check for an open port but does not respond to an ACK packet when it receives a confirmation response. Therefore, the remote server may not log scans.
The -sS
flag and other scan mode switches must run with sudo. For example, the -sP
mode switch will scan the IP address but not the port, acting like the arp below. You can visit the main page of nmap for more scanning modes.
To get longer results, add -vv
or -v3
tags to enable longer logging, create a longer, more readable standard output, depending on the search content, these flags will help you find it. .
Of course, you can use grep
to search for specific results. If you only want to search for port 22, you can run the following command:
nmap scanme.org | grep "22/tcp"
The above command will return status if there is a port and nothing if there is no port.
Scan the active IP address of the local network with arp
arp scans the local area network for connected devices. Because arp is designed to create and edit address resolution protocols, few network scanning tools are available. But it is available on every Mac and is a quick way to get specific information.
To see a list of all devices currently connected to the network, open Terminal and run:
arp -a
The above command returns a list of all devices connected to your network, reporting by IP and MAC address.
You can run arp -a -i en0
to receive only reports from the en0 network interface.
The most powerful tool for scanning local area networks on macOS is nmap. arp is also useful for running pings on the network. Ipconfig can report results for specific interfaces but is more useful when reporting interface information than scanning the network.
I wish you successful implementation!
You should read it
- Instructions to scan the network port with Advanced Port Scanner
- How to determine the device IP address on the local network
- How to Set Up a Local Area Network (LAN)
- Learn 192.168.0.100 IP address for local network
- How to Get MAC Address Using Remote IP Address
- Top 5 IP Scan tools in the best LAN
- Learn about local area network - LAN (Part I)
- Learn about local area networks - LAN: Ethernet - Part II
- Share a folder on the local network for new users
- How to change the default scan type in Microsoft Defender
- Understanding IP address 192.168.1.4
- Understand more about local and global addresses in NAT