2

I'm trying to debug a network problem on a embedded system which has a very limited set of userspace applications. Meaning I can't use any of the following

sudo lsof -i
sudo netstat -lptu
sudo netstat -tulpn

How can i read which sockets are binded from /sys or /proc?

3

Netstat and lsof get their information from /proc/$pid/fd/* for per-process data and from /proc/net/tcp, /proc/net/udp, /proc/net/icmp and /proc/net/raw for IPv4 socket information (and /proc/net/tcp6, /proc/net/udp6 and /proc/net/raw6 for IPv6). The equivalent of your commands is mostly to read these files in /proc/net (plus DNS lookups).

For debugging purposes, consider uploading a binary of lsof to your system, it can be a lot more convenient than rummaging in /proc.

| improve this answer | |
1

You can get the list of binded sockets from /proc/net/tcp[6], /proc/net/udp[6] and /proc/net/raw[6].

Beware if converting the hex values in those files to "normal" IP adresses, they are in little-endian (e.g. 3900060A represents 10.6.0.57 and not 57.0.6.10 as least significant byte comes first).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.