Reputation: 1
On Linux, it's possible to filter packets originating on localhost based on the user or group that created them, i.e. who owns the socket:
iptables ... -m owner --uid-owner $USER --gid-owner $GROUP -p tcp ...
But I want to approach it from the point of view of the program, running on localhost and written in C, receiving the packets: I bound to some port, and here comes a new TCP connection / UDP packets. How to find out who sent that?
Upvotes: 0
Views: 433
Reputation: 3302
Strange use-case, but hey, perhaps something like this could work - but it aint pretty:
accept
using fstat
./proc/self/net/tcp
Upvotes: 2
Reputation: 310979
You can't. You get the remote IP address and port. That's it.
Upvotes: 1