IP and MAC Address In a Script

To get your IP address:
/sbin/ifconfig
   | grep ‘
   | sed -n ‘1p’
   | tr -s ‘ ‘
   | cut -d ‘ ‘ -f3
   | cut -d ‘:’ -f2

To get your MAC address:

/sbin/ifconfig
   | grep ‘eth0’
   | tr -s ‘ ‘
   | cut -d ‘ ‘ -f5

If you have awk, you can use:

/sbin/ifconfig|grep ‘eth’| awk ‘{print $5}’

for MAC address and similar for IP address.

Dodaj odgovor

Vaš e-naslov ne bo objavljen. * označuje zahtevana polja