Watching For I.P. Addresses in C :3

blackneos940

Active Member
Credits
67
So hello everybody..... :3 I have a setup where I need to monitor for any foreign I.P. Addresses..... :3 I know I could just use Wireshark, but I wanna make a Program myself to do this..... :3 I imagine it involves Sockets 'n stuff, but I'm not sure where to go about it..... :\ Any ideas guys.....? :3 Thank you SO much for any help!..... :D
 


JasKinasis

Well-Known Member
Credits
4,005
For monitoring network connections there is always the ss command (socket statistics), which is a part of the iproute2 package. Faster than netstat. Simple to use. It gets all of its information directly from the kernel.

By using ss in a script you should be able to get a list of all open network connections and then filter them by using some of the ss commands options in combination with standard unix tools (grep, ag, sed, awk, less, more etc). That should allow you filter out any connections that you aren't interested in seeing.

That would probably be the simplest solution.

There is a tutorial on the ss command here:
https://www.binarytides.com/linux-ss-command/

As for writing a program to monitor network connections in C - I haven't dealt with any networking related code in the last 10 years, so I'm more than a little rusty with it. So I'm not sure what to suggest offhand!
 

blackneos940

Active Member
Credits
67
For monitoring network connections there is always the ss command (socket statistics), which is a part of the iproute2 package. Faster than netstat. Simple to use. It gets all of its information directly from the kernel.

By using ss in a script you should be able to get a list of all open network connections and then filter them by using some of the ss commands options in combination with standard unix tools (grep, ag, sed, awk, less, more etc). That should allow you filter out any connections that you aren't interested in seeing.

That would probably be the simplest solution.

There is a tutorial on the ss command here:
https://www.binarytides.com/linux-ss-command/

As for writing a program to monitor network connections in C - I haven't dealt with any networking related code in the last 10 years, so I'm more than a little rusty with it. So I'm not sure what to suggest offhand!
Ok!..... :3 Thanks, good sir!..... :3 I still wanna do it in C, but this is something to look at!..... :D
 


Members online


Latest posts

Top