老熟人 发表于 2018-4-15 18:37:10

shell 命令 获取本地IP

shell 命令 获取本地IP
方法一:
/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
or
/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\(\{7,15\}\) .*/\1/p'
方法二:
local_host="`hostname --fqdn`"
local_ip=`host $local_host 2>/dev/null | awk '{print $NF}'`
方法三:
local_host="`hostname --fqdn`"
nslookup -sil $local_host 2>/dev/null | grep Address: | sed '1d' | sed 's/Address://g'

sxbwrx6 发表于 2018-4-15 23:49:26

前排支持一下~~~{:4_110:}

shayu 发表于 2018-4-16 08:15:11

前排支持一下~~~

a1130591816 发表于 2018-8-4 22:21:22


学习一下
666666666支持
签到一下。

a1130591816 发表于 2018-8-4 22:22:22


学习一下
666666666支持
签到一下。

qwerrewq 发表于 2020-2-26 21:19:44

6666666666666666666666

fiuashfui 发表于 2021-4-27 19:58:31

怎么去执行啊
页: [1]
查看完整版本: shell 命令 获取本地IP