Test a TCP port

Checks whether an arbitrary TCP port on a host is reachable.

HTTPS (443)

PowerShell (Windows)

Test-NetConnection Built-in

Test-NetConnection -ComputerName mail.example.com -Port 443 -InformationLevel Detailed

nc / ncat Add-on tool

ncat -vz mail.example.com 443

Unix shell (bash)

bash /dev/tcp Built-in

timeout 5 bash -c "</dev/tcp/mail.example.com/443" && echo open || echo closed

nc Add-on tool

nc -vz mail.example.com 443

SMTP (25)

PowerShell (Windows)

Test-NetConnection Built-in

Test-NetConnection -ComputerName mail.example.com -Port 25 -InformationLevel Detailed

nc / ncat Add-on tool

ncat -vz mail.example.com 25

Unix shell (bash)

bash /dev/tcp Built-in

timeout 5 bash -c "</dev/tcp/mail.example.com/25" && echo open || echo closed

nc Add-on tool

nc -vz mail.example.com 25

LDAPS (636)

PowerShell (Windows)

Test-NetConnection Built-in

Test-NetConnection -ComputerName dc01.example.com -Port 636 -InformationLevel Detailed

nc / ncat Add-on tool

ncat -vz dc01.example.com 636

Unix shell (bash)

bash /dev/tcp Built-in

timeout 5 bash -c "</dev/tcp/dc01.example.com/636" && echo open || echo closed

nc Add-on tool

nc -vz dc01.example.com 636

Ping

Checks a host's basic reachability via ICMP.

PowerShell (Windows)

Test-Connection Built-in

Test-Connection -TargetName mail.example.com -Count 4

ping Built-in

ping -n 4 mail.example.com

Unix shell (bash)

ping Built-in

ping -c 4 mail.example.com

fping Add-on tool

fping -c 4 mail.example.com

Traceroute

Shows the network path to a host hop by hop.

PowerShell (Windows)

Test-NetConnection Built-in

Test-NetConnection -ComputerName mail.example.com -TraceRoute

tracert Built-in

tracert -d mail.example.com

Unix shell (bash)

tracepath Built-in

tracepath mail.example.com

traceroute / mtr Add-on tool

traceroute mail.example.com
mtr -rw -c 10 mail.example.com

traceroute is not always installed on lean Linux servers. mtr gives a continuously updated view.

Who listens on a port?

Shows which process is listening locally on a port.

SMTP (25)

PowerShell (Windows)

Get-NetTCPConnection Built-in

Get-NetTCPConnection -State Listen -LocalPort 25 | Select-Object LocalAddress, LocalPort, OwningProcess
Get-Process -Id (Get-NetTCPConnection -State Listen -LocalPort 25).OwningProcess

netstat Built-in

netstat -ano | findstr ":25 "

Unix shell (bash)

ss Built-in

ss -tlnp "sport = :25"

lsof / netstat Add-on tool

lsof -iTCP:25 -sTCP:LISTEN
netstat -tlnp | grep ":25 "

Submission (587)

PowerShell (Windows)

Get-NetTCPConnection Built-in

Get-NetTCPConnection -State Listen -LocalPort 587 | Select-Object LocalAddress, LocalPort, OwningProcess
Get-Process -Id (Get-NetTCPConnection -State Listen -LocalPort 587).OwningProcess

netstat Built-in

netstat -ano | findstr ":587 "

Unix shell (bash)

ss Built-in

ss -tlnp "sport = :587"

lsof / netstat Add-on tool

lsof -iTCP:587 -sTCP:LISTEN
netstat -tlnp | grep ":587 "

Which DNS server?

Shows which DNS servers the system currently uses: important with split DNS.

PowerShell (Windows)

Get-DnsClientServerAddress Built-in

Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object InterfaceAlias, ServerAddresses

ipconfig Built-in

ipconfig /all

Unix shell (bash)

resolvectl Built-in

resolvectl status

cat Built-in

cat /etc/resolv.conf

Other areas