首页 > 代码库 > liunx下获取网卡地址的几种方法

liunx下获取网卡地址的几种方法

CentOS Linux release 7.2.1511 (Core)系统获取网卡ip
ifconfig em1|awk ‘NR==2 {print $2}‘
ifconfig em1|sed -n ‘2p‘|cut -d ‘ ‘ -f 10
ifconfig em1|sed -n "s/^.*inet \(.*\)  netmask.*$/\1/gp"
grep ‘IPADDR‘ /etc/sysconfig/network-scripts/ifcfg-em1|awk -F ‘=‘ ‘{print $NF}‘
grep ‘IPADDR‘ /etc/sysconfig/network-scripts/ifcfg-em1|awk -F ‘=‘ ‘{print $2}‘

liunx下获取网卡地址的几种方法