慢慢赚钱博客

32 views
5月 26 2021

Linux获取公网出口IP或者私网IP地址

得到本机的公网IP(出口IP)的方法:


curl ifconfig.me
curl -4/-6 icanhazip.com
curl ipinfo.io/ip
curl api.ipify.org
curl checkip.dyndns.org
dig +short myip.opendns.com @resolver1.opendns.com
host myip.opendns.com resolver1.opendns.com
curl ident.me
curl bot.whatismyipaddress.com
curl ipecho.net/plain
The following commands will get you the private IP address of your interfaces:

获取本地私网ip地址的方法:


ifconfig -a
ip addr (或者 ip a)
hostname -I | awk '{print $1}'
ip route get 1.2.3.4 | awk '{print $7}'
nmcli -p device show

Written by moneyslow.com

moneyslow.com真棒!


京ICP备11047313号-19