Helpful commands for networks

Networks and ports are probably the first elements hackers enumerate. Let’s see useful commands to analyze the situation.

Permalink to heading netstat netstat

netstat shows open ports and connections (network statistics):

netstat -ano

With the above command, you can list active connections, state of the sockets, IP addresses, process IDs. It’s available on Windows too.

Permalink to heading nmap nmap

The ultimate enumerator and probably the most popular: light, powerful, Swiss knife. The only inconvenience is the extensive range of options and modes that can be overwhelming for beginners, but there are lots of blog posts and documentations available:


Permalink to heading arp arp

The command dumps the ARP cache, a dynamic list of IP and MAC addresses of the routers your computer communicated with recently:

arp -a

This cache is used by your machine to store information and prevent useless queries every time you communicate with other devices in the same network or external devices.

Permalink to heading nslookup nslookup

nslookup can query a domain server and resolve associated IP addresses:


Permalink to heading ssh ssh

OpenSSH ssh allows you to connect to a remote host. It’s said to be way more secure than the old telnet that transmits all information in plain text.

It checks if the target host is up and encrypts communications. It’s quite straightforward:

ssh user@IP

If your SSH keys (ls ~/.ssh) are authorized on the remote host (cat ~/.ssh/authorized_keys), you can connect without your password:

ssh -i ~/.ssh/YOUR_PRIVATE_KEY user@IP

Permalink to heading ping ping

ping uses ICMP (Internet Control Message Protocol) to send packets to a host and see if it replies:

ping -6 

The above ping command will ping and force IPv6 instead of IPv4.

Permalink to heading traceroute traceroute

traceroute is helpful to retrieve the whole path to a source server. It will also list all routers, also known as “hops,” on the way.

Unlike ping, the purpose of traceroute is not to send a message to get an echo reply that confirms the host is up. Indeed, it’s usually the command you use if ping fails and to determine where packets are lost.

In a security perspective, it can spot anomalies such as unauthorized routers installed by hackers:


N.B: tracert is the equivalent in Windows.