因为公司的云主机使用ifconfig和ip add命令都只能看到内网IP地址,而脚本里面又需要获取公网IP地址进行一些动作;
# ip ad 1: 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 forever 2: 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
这里看不到公网IP,知呢个看到内网IP地址,可以通过curl ip.cip.cc来获取公网IP地址
# curl ip.cip.cc 183.xx.xx.xx
本文出自 “鬼迷心窍” 博客,请务必保留此出处http://dragondragon.blog.51cto.com/6170889/1931615
原文地址:http://dragondragon.blog.51cto.com/6170889/1931615