Question

I am using a CentOS server, and i want to get a remote dynamic ip in a value to use in a script. Right now the script gets the ip like this:

    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. Is there a way to do this with ping or something ? So i can add in current_ip my ip every time the script executes ? -Thanks

Was it helpful?

Solution

To resolve a domain name, try the host utility:

$ host -t A stackoverflow.com
stackoverflow.com has address 198.252.206.140
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top