how to find port numbers a web server is listening to | Unix Linux Forums | IP Networking

  Go Back    


IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

how to find port numbers a web server is listening to

IP Networking


Tags
linux, linux commands

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-09-2007
laddu laddu is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 17 March 2007, 4:42 AM EDT
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
how to find port numbers a web server is listening to

I want to write a program to list all port numbers a process like web server is listening to.Is there a any unix command to find the port numbers and the processes(pid) connected to that port.
Sponsored Links
    #2  
Old 01-10-2007
maheshwin maheshwin is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 29 February 2008, 2:45 AM EST
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by laddu
I want to write a program to list all port numbers a process like web server is listening to.Is there a any unix command to find the port numbers and the processes(pid) connected to that port.

u can write the script in shell for a particular task of listing

in linux we have commands
lsof -i TCP (displays online open tcp ports)
lsof -i UDP
above commands work for linux only

netstat -anp | head -20

nmap -anp ( if the nmap utility is installed in linux system)


thru netstat only we can get much of the information regarding the open ports
Sponsored Links
    #3  
Old 01-10-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
 
Join Date: Nov 2006
Last Activity: 20 November 2013, 8:29 AM EST
Location: Bulgaria
Posts: 1,419
Thanks: 0
Thanked 6 Times in 6 Posts
you can also use "sockstat" if applicable.
    #4  
Old 01-10-2007
maheshwin maheshwin is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 29 February 2008, 2:45 AM EST
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by maheshwin
u can write the script in shell for a particular task of listing

in linux we have commands
lsof -i TCP (displays online open tcp ports)
lsof -i UDP
above commands work for linux only

netstat -anp | head -20

nmap -anp ( if the nmap utility is installed in linux system)


thru netstat only we can get much of the information regarding the open ports

sockstat works on BSD
netstat can be used for unix platform of solaris,hpux
Sponsored Links
    #5  
Old 01-10-2007
Krrishv Krrishv is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 20 August 2014, 1:58 AM EDT
Location: CA,United States
Posts: 204
Thanks: 1
Thanked 0 Times in 0 Posts
netstat -na |grep LISTEN to find the listening ports in HP-UX,Solaris

netstat -na|grep CONNECTED to find the ports connected in Linux box.
Sponsored Links
    #6  
Old 01-22-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 12 January 2013, 3:37 AM EST
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
On solaris:

pfiles <pid>
Sponsored Links
    #7  
Old 02-16-2007
infierno's Avatar
infierno infierno is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 19 April 2008, 5:41 PM EDT
Location: Asuncion, Paraguay
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
You can try, on linux,

Code:
 # netstat -lpn | grep httpd

.. if you know that the server is httpd (apache), there you can figure out what ports and address has apache bound to as well as process' pid.

on freebsd systems try

Code:
# sockstat -ln | grep httpd

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find if remote n/w port is listening on HP-UX from the binary einsteinBrain IP Networking 3 01-19-2012 10:52 AM
how to check remote server port listening from application. einsteinBrain HP-UX 0 01-18-2012 01:33 PM
Find file that maps to a listening port phpfreak Shell Programming and Scripting 2 02-27-2010 08:55 PM
VNC Server http listening port kxchen_home Linux 6 02-06-2004 11:23 PM
port not listening.. Prafulla IP Networking 1 12-12-2001 08:46 AM



All times are GMT -4. The time now is 02:30 PM.