您现在的位置是:网站首页> 编程资料编程资料
Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP_linux shell_
2023-05-26
418人已围观
简介 Shell脚本获取本地网卡IP、mac地址、子网掩码、dns IP、外网IP_linux shell_
#/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地址的3个方法_linux shell_
- Shell脚本实现IP地址合法性判断_linux shell_
- Shell脚本8种字符串截取方法总结_linux shell_
- Shell字符串比较相等、不相等方法小结_linux shell_
- Shell中删除某些文件外所有文件的3个方法_linux shell_
- Shell脚本IF条件判断和判断条件总结_linux shell_
- Shell脚本中判断输入变量或者参数是否为空的方法_linux shell_
- Shell脚本中判断输入参数个数的方法_linux shell_
- Shell最多支持多少个参数?_linux shell_
- Python执行Linux系统命令的4种方法_linux shell_
