可能重复: 在shell脚本中查找公共IP地址
为了在脚本中使用,能够做到这一点很方便:
IP=`....something ....` echo ...$IP... >> configfile
在这个例子中,我正在寻找networking上的IP地址。 Ubuntu,如果它有所作为。 很高兴安装一个或两个包。
IP=`curl ifconfig.me` [stephan@nemesis] ~ $ curl ifconfig.me 173.13.169.18
瞧。 🙂