Shell脚本获取本地⽹卡IP、mac地址、⼦⽹掩码、
dnsIP、外⽹IP
#/usr/bin/envbash
#Name:get_network_
#Author:Purple_Grape
#ThisisascripttogathernetworkinformationofyourLinuxsystem.
#TestunderUbuntu10.04only.
#----------------------------
NIC=eth0
MAC=`LANG=Cifconfig$NIC|awk'/HWaddr/{print$5}'`
IP=`LANG=Cifconfig$NIC|awk'/inetaddr:/{print$2}'|awk-F:'{print$2}'`
MASK=`LANG=Cifconfig$NIC|awk-F:'/Mask/{print$4}'`
ext_ip=``
if[-f/etc/];
then
dns=`awk'/^namerver/{print$2}'/etc/`
fi
#----------------------------
echo"Yournetworkinformationisasbelow:"
echo$MAC
echo$IP
echo$dns
echo$ext_ip
本文发布于:2023-03-15 12:24:24,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/1678854266263842.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:本机外网ip.doc
本文 PDF 下载地址:本机外网ip.pdf
留言与评论(共有 0 条评论) |