Networking Forums

Networking Forums > Computer Networking > Linux Networking > Finding which ports are in use on Linux System.

Reply
Thread Tools Display Modes

Finding which ports are in use on Linux System.

 
 
B. Gandhi
Guest
Posts: n/a

 
      04-18-2004, 02:59 PM
Hi there,

I'd greatly appreciate if someone could please
help me with a problem. I am using a RH Linux
system on which I want to find which ports are
already in use. This I want to do in a program
rather than using some command like lsof. Is
there any API using which I can achieve this.

Thanks,
Bhavin.
 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a

 
      04-18-2004, 03:51 PM
On 18 Apr 2004 07:59:29 -0700, B. Gandhi <(E-Mail Removed)> wrote:
> Hi there,
>
> I'd greatly appreciate if someone could please
> help me with a problem. I am using a RH Linux
> system on which I want to find which ports are
> already in use. This I want to do in a program
> rather than using some command like lsof. Is
> there any API using which I can achieve this.


What kind of ports (i/o ports, network ports, etc.)?

You will likely find that info in /proc. For example network ports in use
can be found in tcp, tcp6, udp and udp6 files in /proc/net/

--
David Efflandt - All spam ignored http://www.de-srv.com/
 
Reply With Quote
 
B. Gandhi
Guest
Posts: n/a

 
      04-18-2004, 10:50 PM
(E-Mail Removed) (David Efflandt) wrote in message news:<(E-Mail Removed)>...
> On 18 Apr 2004 07:59:29 -0700, B. Gandhi <(E-Mail Removed)> wrote:
> > Hi there,
> >
> > I'd greatly appreciate if someone could please
> > help me with a problem. I am using a RH Linux
> > system on which I want to find which ports are
> > already in use. This I want to do in a program
> > rather than using some command like lsof. Is
> > there any API using which I can achieve this.

>
> What kind of ports (i/o ports, network ports, etc.)?
>
> You will likely find that info in /proc. For example network ports in use
> can be found in tcp, tcp6, udp and udp6 files in /proc/net/


I apologize for being vague, yeah, I meant network
ports. Thanks.
 
Reply With Quote
 
Florian Reitmeir
Guest
Posts: n/a

 
      04-19-2004, 01:30 AM
B. Gandhi wrote:

> I'd greatly appreciate if someone could please
> help me with a problem. I am using a RH Linux
> system on which I want to find which ports are
> already in use. This I want to do in a program
> rather than using some command like lsof. Is
> there any API using which I can achieve this.


netstat -nlp

-n numeric
-l listen
-p give me the process number (only usefule if you are root)

in a programm.. you can grep the output of netstat, or get the source of
netstat and look how it manages self to get the ouput.
( with debian a "apt-get source net-tools" should give you the
source/example code)

--
mfG Florian
 
Reply With Quote
 
x86processor
Guest
Posts: n/a

 
      04-19-2004, 04:17 AM
Use netstat to find port information,

#netstat -a | less

x86

Gentoo Linux 1.4 (2.6.5-mm1) / FreeBSD Unix 4.9 - Pentium M 1.40GHz -
512 MB - 40 GB - 14" - 4.5-4.9 lbs - CD-RW/DVD-ROM - Intel
PRO/1000 Gigabit Ethernet - Intel PRO/Wireless Network Connection
802.11b

----------------------------------------
The post originated from Linux Forum:
----------------------------------------
http://www.linuxforum.com
http://www.linuxforum.com/forums


 
Reply With Quote
 
Georg Armbruster
Guest
Posts: n/a

 
      04-19-2004, 06:48 AM
On Sun, 18 Apr 2004 07:59:29 -0700, B. Gandhi wrote:

> I'd greatly appreciate if someone could please
> help me with a problem. I am using a RH Linux
> system on which I want to find which ports are
> already in use. This I want to do in a program
> rather than using some command like lsof. Is
> there any API using which I can achieve this.


Hi B. Gandhi,
give netstat -vatnp
and nmap a try
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listening on many ports on Linux mowaiskhan@gmail.com Linux Networking 4 11-07-2007 09:16 PM
Closing all ports on Linux Leonardo Henrique Machado Linux Networking 6 09-01-2004 05:15 PM
Finding ports Martin Windows Networking 1 08-01-2004 07:08 AM
Need to install a 'small linux' - help required in finding one AAVF IT Linux Networking 16 06-19-2004 09:42 AM
CD Rom and system not finding it Greg Broadband Hardware 0 01-24-2004 11:52 PM



1 2 3 4 5 6 7 8 9 10 11