3

I'm trying to debug a network problem on an embedded system which has a very limited set of user space applications. That is, I can't use any of the following

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

How can I read which sockets are bound from /sys or /proc?

2 Answers 2

4

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.

2

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .