#/usr/bin/env bash # Name: get_network_info.sh # Author: Purple_Grape # This is a script to gather n
#/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
--结束END--
本文标题: Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP
本文链接: https://www.lsjlt.com/news/18199.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-30
2024-04-30
2024-04-30
2024-04-29
2024-04-29
2024-04-29
2024-04-18
2024-04-17
2024-04-11
2024-04-08
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0