Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Sunday, May 1, 2022

Check open ports linux

 how to check open ports in ubuntu using nmap

first install nmap

# sudo apt install nmap

then type this command to check open ports.

 

# nmap -sT -O localhost

result look like this,

root@host:~# nmap -sT -O localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2022-04-30 16:28 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00015s latency).
Not shown: 982 closed ports
PORT      STATE SERVICE
21/tcp    open  ftp
22/tcp    open  ssh
25/tcp    open  smtp
53/tcp    open  domain
80/tcp    open  http
110/tcp   open  pop3
143/tcp   open  imap
443/tcp   open  https
465/tcp   open  smtps
587/tcp   open  submission
631/tcp   open  ipp
993/tcp   open  imaps
995/tcp   open  pop3s
3306/tcp  open  mysql
8000/tcp  open  http-alt
8081/tcp  open  blackice-icecap
10024/tcp open  unknown
10025/tcp open  unknown
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6.32
OS details: Linux 2.6.32
Network Distance: 0 hops

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.11 seconds

But if you want to check open ports from other side.

for TCP ports check

# nc -z -v localhost 1-65535 2>&1 | grep succeeded

here is the result


akwal:/# nc -z -v localhost 1-65535 2>&1 | grep succeeded
Connection to localhost 21 port [tcp/ftp] succeeded!
Connection to localhost 22 port [tcp/ssh] succeeded!
Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to localhost 80 port [tcp/http] succeeded!
Connection to localhost 443 port [tcp/https] succeeded!
Connection to localhost 3306 port [tcp/mysql] succeeded!

for UDP ports check add -u

# nc -z -v -u localhost 1-65535 2>&1 | grep succe

akwal:/# nc -z -v -u localhost 1-65535 2>&1 | grep succeeded
Connection to localhost (::1) 53 port [udp/domain] succeeded!
Connection to localhost (::1) 123 port [udp/ntp] succeeded!


That's it,