Is there a way to get the IP (v4) address of an interface in the file system of Android? I know I could use ifconfig or netcfg but I would like to use a monitoring tool which can only access files and not execute commands.
According to a post on SO,
cat /proc/net/tcp will return it in
the second column, with the heading "local_address", e.g. "CF00A8C0:0203".
The part after ":" is a port number.
From the rest use the last two (C0) as a hex number, e.g. C0 is 192, which is the start of the address in this example.
The IP address is displayed as a little-endian four-byte hexadecimal number; that is, the least significant byte is listed first, so you'll need to reverse the order of the bytes to convert it to an IP address.
The port number is a simple two-byte hexadecimal number.
I have no Android to test it, but Linux offers:
The output can then be filtered further by grep, e.g.
cat /proc/net/fib_trie|grep '|--' | grep -vE ' 127|\.0[^0-9.]*$|\.255[^0-9.]*$'