Jump to content


Photo

Check what ports are open


4 replies to this topic

#1 xDamox

xDamox

    Linux-Noob Frequent Member

  • Members
  • PipPipPip
  • 390 posts

Posted 16 January 2005 - 06:52 PM

There are two good methods to see what ports are open in Linux you can use
nmap which is a port scanner and you can use netstat.

nmap can be used to scan your machine to see whats ports are open issue the
following command to scan your computers machine:

nmap -sS -O 127.0.0.1

once the scan has finished you will get the following ouput:

Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2005-01-16 05:48 GMT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1656 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
443/tcp  open  https
1241/tcp open  nessus
Device type: general purpose
Running: Linux 2.4.X|2.5.X|2.6.X
OS details: Linux 2.5.25 - 2.6.3 or Gentoo 1.2 Linux 2.4.19 rc1-rc7)
Uptime 1.985 days (since Fri Jan 14 06:10:41 2005)

Nmap run completed -- 1 IP address (1 host up) scanned in 2.341 seconds

The second method was netstat. netstat can show hidden ports and what programs using
them issue the following command as root:

netstat -nap

This will show you the output of something similar to:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 127.0.0.1:61931             0.0.0.0:*                   LISTEN      5277/wish
tcp        0      0 127.0.0.1:5335              0.0.0.0:*                   LISTEN      3920/mDNSResponder
tcp        0      0 0.0.0.0:1241                0.0.0.0:*                   LISTEN      31438/nessusd: wait
tcp        0      0 10.0.0.14:32776             194.109.129.220:6667        ESTABLISHED 5062/xchat
tcp        0      0 10.0.0.14:45731             207.46.107.146:1863         ESTABLISHED 5277/wish
tcp        0      0 10.0.0.14:33009             82.96.64.2:6667             ESTABLISHED 5062/xchat
tcp        0      0 :::80                       :::*                        LISTEN      4355/httpd
tcp        0      0 :::22                       :::*                        LISTEN      32372/sshd
tcp        0      0 :::443                      :::*                        LISTEN      4355/httpd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           3614/dhclient
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           3920/mDNSResponder


#2 P38

P38

    Linux-Noob Frequent Member

  • Supporters
  • PipPipPip
  • 141 posts

Posted 17 January 2005 - 05:38 AM

When you are looking for open ports on your machine, scanning 127.0.0.1 will not necessarily show you anything that is exposed. Most firewall configurations allow full access from the local machine to 127.0.0.1. If you are interested in determining what ports others might be able to see and potentially exploit, you should scan your machine from another machine to your IP address that is exposed to the external world.
P38

I look much better online.

#3 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 21 March 2005 - 10:53 PM

Adding to what P38 said.. scanning within a LAN will not show everything that is exposed either. Again the external IP is the way around this...

#4 grep420

grep420

    Linux-Noob Frequent Member

  • Members
  • PipPipPip
  • 119 posts

Posted 24 March 2005 - 08:35 AM

I like to use netstat -ntulp that will show everything that is listening tcp and udp and the ip that it is listening on.
Four whores and seven beers ago.

#5 dspln

dspln

    Noob

  • Members
  • Pip
  • 20 posts

Posted 05 December 2005 - 11:21 PM

before I learned of netstat, I started using
lsof -i -n -P
seems to give a bit more info

(or just lsof to get a dump of all open files - long list :) )

Edited by dspln, 05 December 2005 - 11:22 PM.




Reply to this topic



  


2 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users


    Google (1)