12

I already figured out that on Linux I can list network devices

(cd /proc/net/dev_snmp6/ && for device in *; do echo $device; done|sort)

but how can I get the ipv4 address of the device?

I do not have ifconfig/ip installed - and I'd like to keep it this way.

Mandragor
  • 1,060
  • basically net-tools are not installed and i want to just "standard" unix tools, like cat / sed/ awk /bash – Mandragor Feb 16 '17 at 19:12
  • See this answer : https://unix.stackexchange.com/a/48315/153195 – GAD3R Dec 16 '18 at 10:33
  • 3
    @GAD3R, Thomas, Rui F Riberio: I think you all misread the question. You've linked a completely unrelated question while marking dup.

    Here's a better one with answers in bash, python, and C: https://stackoverflow.com/q/5281341/141023

    – cheshirekow Feb 11 '19 at 19:12
  • 1
    hostname -I does the work. – Rahmani Aug 19 '21 at 07:19

1 Answers1

1

Using netstat -ie you should be able to see all interfaces and any information associated with them.

Example:

user@host:~$ netstat -ie
Kernel Interface table

eth0      Link encap:Ethernet  HWaddr 00:16:3e:09:da:c8  
          inet addr:43.96.21.119  Bcast:43.96.21.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:63671638 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48175503 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12361708203 (12.3 GB)  TX bytes:12765881974 (12.7 GB)
ProdIssue
  • 875
  • 11
    thanks for pointing out netstat, but this is also part of the net-tools which are not installed (ifconfig etc.) – Mandragor Feb 16 '17 at 19:12