获取本机IP

  sre

ifconfig -a |grep inet |grep -v ‘127.0.0.1’ |grep -v ‘inet6’ |awk ‘{print 2}’ |tr -d ‘addr:’
ifconfig |grep ‘inet addr’ |grep -v ‘127.0.0.1’ |cut -d: -f2 |awk ‘{print
1}’
ifconfig -a |sed -n ‘/inet add/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p’

local_host=”`hostname –fqdn`”
nslookup -sil local_host 2>/dev/null | grep Address: | sed ‘1d’ | sed ‘s/Address://g’

local_host=”`hostname –fqdn`”
local_ip=`hostlocal_host 2>/dev/null | awk ‘{print $NF}’`

2 thoughts on - 获取本机IP

LEAVE A COMMENT

Captcha Code