How do I know which ports an application opens

  • Follow


Hello, 
I ran a unix application ; I want to know which ports
these application opens. 
(This application simply opens sockets with 2 or 3 ports). 

How can I do it ? 

I of course can do it indirectly. 
For example, run nmap before starting the application and 
after starting it , and see the difference in ports. 
but is there a direct way ? 
regards,
sting
0
Reply zstingx (21) 12/10/2003 1:16:25 PM

In article <2ff4a208.0312100516.1d384887@posting.google.com>, Sting wrote:
> Hello, 
> I ran a unix application ; I want to know which ports
> these application opens. 
> (This application simply opens sockets with 2 or 3 ports). 
> 
> How can I do it ? 
> 
> I of course can do it indirectly. 
> For example, run nmap before starting the application and 
> after starting it , and see the difference in ports. 
> but is there a direct way ? 
try netstat , depending on which OS your on, it might show
you pid<->port relations.

-- 
Vennlig hilsen/Best Regards
Nils Olav Sel�sdal <NOS at Utel.no>
System Engineer
UtelSystems a/s

0
Reply noselasd 12/10/2003 1:22:57 PM


2003-12-10, 05:16(-08), Sting:
> I ran a unix application ; I want to know which ports
> these application opens. 
> (This application simply opens sockets with 2 or 3 ports). 
[...]

lsof -ai -c <cmd-name>

or

lsof -ai -p <pid>

List the opened sockets (either listening or connected ones, TCP
or UDP).

lsof -i
lists every opened socket on your system.

-- 
St�phane                      ["Stephane.Chazelas" at "free.fr"]
0
Reply Stephane 12/10/2003 3:11:39 PM

Nils O. Sel�sdal wrote:

> In article <2ff4a208.0312100516.1d384887@posting.google.com>, Sting wrote:
>> Hello,
>> I ran a unix application ; I want to know which ports
>> these application opens.
>> (This application simply opens sockets with 2 or 3 ports).
>> 
>> How can I do it ?

Look up this program: http://freshmeat.net/projects/lsof/

It's *very* handy for doing this kind of thing. It shows all open file
descriptors for a process. You can just grep the output for the socket
connections.
0
Reply HR 12/11/2003 6:14:26 AM

3 Replies
222 Views

(page loaded in 0.062 seconds)


Reply: