Operating System - HP-UX
1753563 Members
5480 Online
108796 Solutions
New Discussion юеВ

Re: Finding port number of a service

 
Raghvinder Sangwan
Occasional Contributor

Finding port number of a service

How can one get a list of all the services running on an hp-ux server along
with the port numbers they are using? I am aware that some information can be
obtained from /etc/services but what about services not listed in
/etc/services?

Thanks!
Raghu
3 REPLIES 3
Paul Hite_2
Frequent Advisor

Re: Finding port number of a service

Try this command:
netstat -an | grep LISTEN
Raghvinder Sangwan
Occasional Contributor

Re: Finding port number of a service

Hi Paul:

When I use netstat -an | grep LISTEN I get an output similar to the following:

tcp 0 0 *.80 *.* LISTEN
tcp 0 0 *.2121 *.* LISTEN
tcp 0 0 *.37 *.* LISTEN
tcp 0 0 *.25 *.* LISTEN
tcp 0 0 *.23 *.* LISTEN

How do you tell from this output what service is running on a given port. For
example, port 80 is the web server, port 25 is the mail server, etc.

Thanks!
Raghu
Paul Hite_2
Frequent Advisor

Re: Finding port number of a service

Well, there is no magic way to know what, say 2121 is doing. Ports 25 and 80
are well known ports and are listed in /etc/services. If someone writes a
program and does a listen on port 2121 but does not update /etc/services or
otherwise tell you about it, there is no way to forcibly extract the
information by program.

Indeed that program that is doing the listen on port 2121 may be so
disfunctional that it offers no services at all. What then?

I'm not sure what you expect a program to do about undocumented ports.