centos shell get ip mac address

--------------------------------mac------------------------

cat /sys/class/net/eth*/address

 

-------------------------mac-----------------------------

/sbin/ifconfig \
   | grep 'eth0' \
   | tr -s ' ' \
   | cut -d ' ' -f5

------------------ip--------------------------
/sbin/ifconfig \
   | grep '\<inet\>' \
   | sed -n '1p' \
   | tr -s ' ' \
   | cut -d ' ' -f3 \
   | cut -d ':' -f2
--------------------------mac----------------
ifconfig | grep HWaddr | awk -F" " '{print $5}'

------------------------ip-------------------------
ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top