Because the company's cloud host use ifconfig and IP add command can only see the intranet IP address, and the script also need to get the public IP address for some action;
# ip ad1: lo: <loopback,up,lower_up> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft Forever preferred_lft forever2: eth2: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 08:00:27:d9:18:4e brd ff:ff:ff:ff:ff:ff inet 192.168.1.191/24 brd 192.168.1.255 scope global eth2 inet6 fe80::a00:27ff :fed9:184e/64 scope link valid_lft forever Preferred_lft forever
There is no public network IP, know what to see the intranet IP address, you can get the public IP address via Curl ip.cip.cc
# Curl IP.CIP.CC183.XX.XX.XX
This article is from the "obsessed" blog, make sure to keep this source http://dragondragon.blog.51cto.com/6170889/1931615
Linux Cloud host gets the native public IP address