主頁 > 知識庫 > Shell腳本獲取本地網(wǎng)卡IP、mac地址、子網(wǎng)掩碼、dns IP、外網(wǎng)IP

Shell腳本獲取本地網(wǎng)卡IP、mac地址、子網(wǎng)掩碼、dns IP、外網(wǎng)IP

熱門標簽:AI電銷 Linux服務器 服務外包 網(wǎng)站排名優(yōu)化 地方門戶網(wǎng)站 呼叫中心市場需求 鐵路電話系統(tǒng) 百度競價排名

#/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

您可能感興趣的文章:
  • 獲取同一網(wǎng)段下所有機器MAC地址的shell腳本

標簽:崇左 湖南 仙桃 衡水 湘潭 蘭州 銅川 黃山

巨人網(wǎng)絡通訊聲明:本文標題《Shell腳本獲取本地網(wǎng)卡IP、mac地址、子網(wǎng)掩碼、dns IP、外網(wǎng)IP》,本文關鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266