海阔中文网

165 views
5月 26 2021

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

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


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

获取ipv6地址:
curl https://4ipv6.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

Written by 海阔中文网

海阔中文网真棒!


京ICP备11047313号-20