- 作者:zhijie
- 时间:2023-02-10
使用 DYDNS (当你使用 DYDNS 服务时有用)
curl -s ‘http://checkip.dyndns.org’ | sed ‘s/.*Current IP Address: \([0-9\。]*\).*/\1/g’
curl -s http://checkip.dyndns.org/ | grep -o “[[:digit:]。]\+”
使用 Wget 代替 Curl
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
使用 host 和 dig 命令
如果有的话,你也可以直接使用 host 和 dig 命令。
host -t a dartsclink.com | sed ‘s/.*has address //’
dig +short myip.opendns.com @resolver1.opendns.com
bash 脚本示例:
#!/bin/bash
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP
以上就是Linux终端查看公有IP的方法的全部内容了,得知Linux公有IP对于使用服务器的用户来所有很大的意义,因为服务器下的IP就是公有IP。