[英]get remote ip of address in a value for use in shell script
I am using a CentOS server, and i want to get a remote dynamic ip in a value to use in a script. 我正在使用CentOS服务器,并且我想获取一个远程动态ip值以用于脚本中。 Right now the script gets the ip like this: 现在,脚本将获得如下所示的ip:
current_ip=$(curl --silent http://ipecho.net/plain)
but since i am moving the script to a server, i need it to ping my dyndns domain name and get my ip since its going to be changing every now and then. 但是由于我将脚本移动到服务器,所以我需要它来ping我的dyndns域名并获取我的IP,因为它会不时地发生变化。 Is there a way to do this with ping or something ? 有办法用ping或其他方法做到这一点吗? So i can add in current_ip my ip every time the script executes ? 所以我可以在每次执行脚本时在current_ip中添加我的IP吗? -Thanks -谢谢
To resolve a domain name, try the host
utility: 要解析域名,请尝试使用host
实用程序:
$ host -t A stackoverflow.com
stackoverflow.com has address 198.252.206.140
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.