Checking open ports

A simple and quite often task to check open ports on a Linux host

Using netcat:

$ nc -v -z <url&ip> <port>

~# nc -v -z smtp.domain.name 25

Connection to smtp.domain.name 25 port [tcp/smtp] succeeded!

Using tcpdump to see how are packets transferring:

 ~ # tcpdump -i any -n tcp port 25

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes

08:16:59.034791 IP 156.153.57.163.49616 > 236.233.15.164.10053: Flags [S], seq 3901328647, win 29200, options [mss 1460,sackOK,TS val 3647396634 ecr 0,nop,wscale 7], length 0

08:16:59.034810 IP 236.233.15.164.49616 > 192.168.1.105.10053: Flags [S], seq 3901328647, win 29200, options [mss 1460,sackOK,TS val 3647396634 ecr 0,nop,wscale 7], length 0

Using netstat:

~$ netstat -l

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State

tcp        0      0 0.0.0.0:pop3s           0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:10053           0.0.0.0:*               LISTEN

options are:

to check open tcp ports 

~$ netstat -vatn

Using telnet:

~ # telnet 192.168.1.105 25

Trying 192.168.1.105…

Connected to 192.168.1.105.

Escape character is ‘^]’.

Other Links:

https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

https://www.cyberciti.biz/faq/how-do-i-find-out-what-ports-are-listeningopen-on-my-linuxfreebsd-server/

Have You More questions? Please be free to ask us your questions in the
Dzhumaiev.Slack.com channel 🙂

Leave a Reply