LInux获取IP地址

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

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


国内首选
curl cip.cc
curl myip.ipip.net

获取ipv6地址:
curl https://ipv6.moneyslow.com


国外
curl http://members.3322.org/dyndns/getip
curl ifconfig.me
curl ipinfo.io
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

另外还有个测试出口ip速度排名的脚本: