DEV Community

webduvet
webduvet

Posted on

Scanning for open ports

lsof

list of open files

lsof -i -P -n | grep LISTEN
Enter fullscreen mode Exit fullscreen mode

netstat

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

netstat -tulpn | grep LISTEN
Enter fullscreen mode Exit fullscreen mode

ss

utility to investigate sockets

ss -tulpn | grep LISTEN
Enter fullscreen mode Exit fullscreen mode

nmap

network exploration tool, port scanner

nmap -open 192.168.3.34
Enter fullscreen mode Exit fullscreen mode

scanning open ports on remote IP address

nc -zv 192.168.3.34 2>&1 1-1024 | grep -v refused
Enter fullscreen mode Exit fullscreen mode

this scans open ports in the range of 1 to 1024 on the above IP address.
redirects the error output to standard outoput and matches all lines except refused

scanning all open ports on the subnet using nmap

nmap -n 192.168.3.0/24
Enter fullscreen mode Exit fullscreen mode

Sources

Latest comments (0)