LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2008, 07:38 AM   #1
qnguyendang
LQ Newbie
 
Registered: Jan 2003
Posts: 10

Rep: Reputation: 0
detection opening/closing port


Hi,

I plan to write a program which detects closing/opening port (tcp/udp port) events. Whenever a port is opened by an application, or a port is released, my program will be able to detect this event and write this to a log file. I think it is not very difficult but I have no idea to start.

Could anybody help me? Is there any support by Linux for this issue?

Thank you very much,

Nguyen.
 
Old 12-13-2008, 03:28 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,288

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Let me suggest:

the LDP project has guides for linux programmers, iirc.
http://www.insecure.org has nmap, which overlaps with your project.
The kernel docs have a list of ports, and the purpose they are assigned to.

I think this is all managed by the kernel, so your programming exercise will be trivial. Too trivial to impress.
 
Old 12-13-2008, 05:52 PM   #3
qnguyendang
LQ Newbie
 
Registered: Jan 2003
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks for your suggestion, business_kid.

But I want to explain a little more. I do not tend to detect remote ports. And I do not also want to scan ports actively. My program aims to listen passively and it will be triggered by any port opening/closing event, then it write this event to log file. That is my idea.

If nmap can help, please tell me more detail. But if I understand correctly, it may be not really relevant.

I am waiting for any other idea.

Thank you.

Nguyen.
 
Old 12-14-2008, 09:34 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,288

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Try

nmap 127.0.0.1
 
Old 12-14-2008, 06:25 PM   #5
Tinker06
LQ Newbie
 
Registered: Apr 2006
Location: Poulsbo, WA
Distribution: Debian
Posts: 5

Rep: Reputation: 1
He hears you, but he's not really listening.

Try netstat -tn

Once you understand what this is showing you, write something to run that frequently and process the output. UDP might be a little harder since that protocol is "connectionless" by definition.

Cheers
 
Old 12-15-2008, 07:28 PM   #6
qnguyendang
LQ Newbie
 
Registered: Jan 2003
Posts: 10

Original Poster
Rep: Reputation: 0
Hi,

The try both your suggestions. I understand the output. But the key point here is that I do not want to check frequently like that. Instead, an event will trigger my program. I think auditd is quite suitable in this case.

Sorry making you confusing because of my poor explanation.

Thanks,

Nguyen.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
serial port opening and closing byte derek_ou Programming 2 08-27-2008 11:14 AM
cpu is closing and opening on it's own fakhruddinhd Linux - Software 3 09-06-2006 09:10 AM
Opening and closing ports stormtracknole Slackware 10 01-11-2006 08:29 AM
opening/closing window sounds matt_com911 Fedora 1 06-18-2005 09:17 PM
Opening/Closing Ports on Debian 3.0 addowen Linux - Newbie 0 04-22-2004 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration