3

Is there a way using only ifconfig to list only network interface names and their assigned IPs?

I am aware that I can do ifconfig | grep inet but this does not include the interface name (en0, en1 etc)

  • ifconfig is mainly configuration utility, the netstat is information utility – Ruskes Jun 16 '14 at 9:03
1

Netstat vs ifconfig.

Netstat -i is closest I can find for what you want (it does bit more then you asked).

Name  Mtu   Network       Address            Ipkts Ierrs    Opkts Oerrs  Coll
lo0   16384 <Link#1>                          7096     0     7096     0     0
lo0   16384 localhost   ::1                   7096     -     7096     -     -
lo0   16384 127           localhost           7096     -     7096     -     -
lo0   16384 localhost   fe80:1::1             7096     -     7096     -     -
gif0* 1280  <Link#2>                             0     0        0     0     0
stf0* 1280  <Link#3>                             0     0        0     0     0
en0   1500  <Link#4>    14:10:9f:f0:29:8c   380920     0   292385     0     0
en0   1500  mynet.local fe80:4::1610:9fff   380920     -   292385     -     -
en0   1500  10.5.50/24    10.5.50.95        380920     -   292385     -     -
en3   1500  <Link#5>    32:00:1a:e9:a9:a0        0     0        0     0     0
bridg 1500  <Link#6>    16:10:9f:0f:1e:00        0     0        0     0     0
p2p0  2304  <Link#7>    06:10:9f:f0:29:8c        0     0        0     0     0
4

You could run ifconfig -l to get a list of interfaces, then iterate through them.

(bash)

for i in `ifconfig -l `; do echo $i; ifconfig $i | grep "inet " ; done

This will print the interface on one line, and the "inet " info on the next line. Note that if you only search for "inet", the "inet6" line will also show up.

You must log in to answer this question.

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