Ifconfig
From Attie's Wiki
awk
This awk script will extract the configuration settings for an interface from the /etc/network/interfaces
file.
Contents of 'ifaceExtract':
BEGIN { i = 0; got = 0; if (iface = "") iface="eth0"; addr = "192.168.1.1"; mask = "255.255.255.0"; } { if ($1 == "iface") { if ($2 == iface) { i=1; got=1; } else { i=0; } } if (i) { if ($1 == "address") addr = $2; else if ($1 == "netmask") mask = $2; } } END { if (got) printf "ifconfig %s %s netmask %s\n", iface, addr, mask; else print "echo No interface " iface "..." }
awk -v iface=eth2 -f ifaceExtract /etc/network/interfaces
Set the 'iface
' variable to the interface you wish to probe
Expected output is as follows:
ifconfig eth0 10.150.129.115 netmask 255.255.255.224
echo No interface eth3...
This means that it is possible to surround the awk script in backticks (``), and execute its output!