3

This is NOT a duplicate of How to get my own IP address and save it to a variable in a shell script? ; it is an attempt to revicve How can I list net work devices and ipv4 address on linux without ifconfig/ip command which has mistakenly been marked as a duplicate of the first.

So, in a system where neither ip, netstat or ifconfig are available, how is it possible to see the legacy IPv4 adresses?

The system is a docker container running lastest debian.

Lenne
  • 181

2 Answers2

5

Interfaces: /proc/net/dev

There are no /proc or /sys files which have IP addresses but they can be extracted indirectly if you have listening services or open connections. Check: /proc/net/tcp and /proc/net/tcp6.

0

Another option is busybox. It includes both ifconfig and ip implementations.

Another option is to write own subset of ip to use netlink to request the relevant data. You could also use the ioctl(2) interfaces used by ifconfig.

Another option is to check the log files written by your DHCP client. In fact, it would not be surprising if it records your lease to disk. It might be in /var/lib/dhcp/ (at least, mine is). If you need to do something with the address on a regular basis, you might modify the script that is used to update the system when the lease is obtained.

David G.
  • 1,369