How to query the public IP address of a Linux server

There are many situations in our work that require us to get the public IP of the current machine

method 1

Visit a nginx with a public IP machine and check the status recorded in the nginx calendar. This method is suitable for many situations and is used to obtain the export IP (that is, the public IP of the machine)

Method 2

查询公网IP
curl icanhazip.com
curl ifconfig.me
curl curlmyip.com
curl ip.appspot.com
curl ipinfo.io/ip
curl ipecho.net/plain
curl www.trackip.net/i
curl cip.cc
curl ip.cip.cc #这个我用的最多

#上面的命令不一定都能连通,需要测试

Note that the public IP obtained by the curl command does not mean that this public IP is bound to the current machine

Insert picture description here

Reference

https://my.oschina.net/epstar/blog/513186

Guess you like

Origin blog.csdn.net/xys2015/article/details/114001915