Você também pode usar ifdata
para obter informações sem analisar a saída de ip
com grep
, awk
ou outras ferramentas:
[~]$ ifdata -pa eth0
192.168.246.161
[~]$ ifdata -pn eth0
255.255.240.0
[~]$ ifdata
Usage: ifdata [options] iface
-e Reports interface existence via return code
-p Print out the whole config of iface
-pe Print out yes or no according to existence
-pa Print out the address
-pn Print netmask
-pN Print network address
-pb Print broadcast
-pm Print mtu
-ph Print out the hardware address
-pf Print flags
-si Print all statistics on input
-sip Print # of in packets
-sib Print # of in bytes
-sie Print # of in errors
-sid Print # of in drops
-sif Print # of in fifo overruns
-sic Print # of in compress
-sim Print # of in multicast
-so Print all statistics on output
-sop Print # of out packets
-sob Print # of out bytes
-soe Print # of out errors
-sod Print # of out drops
-sof Print # of out fifo overruns
-sox Print # of out collisions
-soc Print # of out carrier loss
-som Print # of out multicast
-bips Print # of incoming bytes per second
-bops Print # of outgoing bytes per second