shell获取本地网卡IP,mac,掩码,dns,外网IP
2014-01-20 11:39
627 查看
#/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
# 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
- Linux下获取IP、MAC、网关、掩码的shell脚本
- Linux下获取IP、MAC、网关、掩码的shell脚本
- 获取网卡物理位址与网关掩码 DNS IP
- 获取本地ip,dns 以及 mac等ipconfig/all信息代码
- Linux下获取IP、MAC、掩码的shell脚本
- Android如何获取外网和本地的ip
- shell脚本获取网卡的IP
- shell 根据用户的要求修改ip获取方式 并修改ip以及掩码
- c#获取本地IP和MAC地址
- java根据本地IP获取mac地址的方法
- 获取本地Mac地址,服务器IP,及验证
- C# 获取本地IP客户端IP地址以及MAC地址
- Android 获取本地外网IP、内网IP、计算机名等信息
- javascript获取本地及外网IP地址
- Python获取本机所有网卡ip,掩码和广播地址
- linux下的shell命令的编写,以及java怎样调用linux的shell命令(java怎样获取linux上的网卡的ip信息)
- java 获取本地的或者外网的IP
- 获取外网IP和本机所有网卡地址信息