How can I list net work devices and ipv4 address on linux without ifconfig/ip command

17,548

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)
Share:
17,548

Related videos on Youtube

Mandragor
Author by

Mandragor

Updated on September 18, 2022

Comments

  • Mandragor
    Mandragor almost 2 years

    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.

    • Admin
      Admin over 7 years
      basically net-tools are not installed and i want to just "standard" unix tools, like cat / sed/ awk /bash
    • Admin
      Admin over 5 years
    • Admin
      Admin over 5 years
      @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: stackoverflow.com/q/5281341/141023
    • Admin
      Admin almost 3 years
      hostname -I does the work.
  • Mandragor
    Mandragor over 7 years
    thanks for pointing out netstat, but this is also part of the net-tools which are not installed (ifconfig etc.)