多网卡下获取本机hostname的ip

启动了docker容器,网卡较多。
只需要获取hostname对应的ip:

local_host="`hostname --fqdn`"
ServiceIP=`nslookup -sil $local_host 2>/dev/null | grep Address: | sed '1d' | sed 's/Address://g'`
echo ${ServiceIP}

posted @ 2020-11-17 09:19  邹姣姣  阅读(608)  评论(0编辑  收藏  举报