脚本宝典收集整理的这篇文章主要介绍了Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
#/usr/bin/env bash # Name: get_network_info.sh # Author: Purple_GraPE # This is a script to gather network information of your Linux System. # test under ubuntu 10.04 only. #---------------------------- NIC=eth0 MAC=`LANG=C ifconfig $NIC | awk '/HWaddr/{ PRint $5 }' ` IP=`LANG=C ifconfig $NIC | awk '/inet addr:/{ print $2 }' | awk -F: '{print $2 }'` MASK=`LANG=C ifconfig $NIC | awk -F: '/Mask/{print $4}'` ext_ip=`curl ifconfig.me` if [ -f /etc/resolv.conf ]; then dns=`awk '/^nameserver/{print $2}' /etc/resolv.conf ` fi #---------------------------- echo "Your network information is as below:" echo $MAC echo $IP echo $dns echo $ext_ip
以上是脚本宝典为你收集整理的Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP全部内容,希望文章能够帮你解决Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。