命令1.使用wget
wget http://ipecho.net/plain -O - -q ; echo
命令2:使用curl
curl ipecho.net/plain; echo
命令3:使用wget
wget http://observebox.com/ip -O - -q ; echo
命令4:使用curl
curl icanhazip.com
命令5:使用curl
curl ifconfig.me
获取公网IP的Shell脚本
我们可以将其命令存储在shell脚本中的任何位置,并简单地使用shell脚本来获取电脑的公网IP。
#!/bin/bash
PUBLIC_IP=wget http://ipecho.net/plain -O - -q ; echo
echo $PUBLIC_IP