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.

4
  • basically net-tools are not installed and i want to just "standard" unix tools, like cat / sed/ awk /bash
    – Mandragor
    Commented Feb 16, 2017 at 19:12
  • See this answer : unix.stackexchange.com/a/48315/153195
    – GAD3R
    Commented Dec 16, 2018 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: stackoverflow.com/q/5281341/141023 Commented Feb 11, 2019 at 19:12
  • 1
    hostname -I does the work.
    – Rahmani
    Commented Aug 19, 2021 at 7:19

1 Answer 1

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)
1
  • 13
    thanks for pointing out netstat, but this is also part of the net-tools which are not installed (ifconfig etc.)
    – Mandragor
    Commented Feb 16, 2017 at 19:12

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