linux显示网络参数

IPADDR=`ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | cut -d' ' -f1`

NETMASK=`ifconfig eth0 | grep "inet addr:" | cut -d: -f4`

GATEWAY=`route | grep default | cut -d' ' -f10`

NAMESERVER=`cat /etc/resolv.conf | grep nameserver | cut -d' ' -f2`

echo "##################################"

echo "## IPADDRESS: ${IPADDR} ##"

echo "## NETMASK: ${NETMASK} ##"

echo "## GATEWAY: ${GATEWAY} ##"

echo "## NAMESERVER:${NAMESERVER} ##"

echo "##################################"

160801205.jpg

spacer.gifIPADDR=`ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | cut -d' ' -f1`

NETMASK=`ifconfig eth0 | grep "inet addr:" | cut -d: -f4`

GATEWAY=`ip route | grep default | awk '{print $3}'`

NAMESERVER=`cat /etc/resolv.conf | grep nameserver | cut -d' ' -f2`

echo "##################################"

echo "## IPADDRESS: ${IPADDR} ##"

echo "## NETMASK: ${NETMASK} ##"

echo "## GATEWAY: ${GATEWAY} ##"

echo "## NAMESERVER:${NAMESERVER} ##"

echo "##################################"

你可能感兴趣的:(linux,网络,default)