Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.