l2t

How to ping and test for a specific port in Linux?

Asked: 5 months ago

The ping command can not be used to ping a specific port. Followings are some other ways to ping to specific port.

ping port using telnet command

telnet <HOST> <PORT>
telnet www.google.com 80
telnet 172.217.164.196 80

Ping using nc command

nc -vz <HOST> <PORT>
nc -vz 172.217.164.196 80
nc -vz www.googl.com 443

Ping port using nmap command

nmap -PNp <HOST> <PORT>
nmap -p <HOST> <PORT>
nmap -p 443 www.googl.com
nmap -p 443 172.217.164.196

Use bash shell to check port

(echo >/dev/tcp/<HOST>/<PORT>) &>/dev/null && echo "open" || echo "close"
(echo >/dev/udp/<HOST>/<PORT>) &>/dev/null && echo "open" || echo "close"
(echo >/dev/tcp/www.google.com/443) &>/dev/null && echo "Open 443" || echo "Close 443"

Use nping command

sudo nping --tcp -p <PORT> <HOST>
sudo nping --tcp -p 443 www.google.com
Viewed: 154 times
Liked: 1 times