This script checks whether current ip is the same as the previous one, if not, calls namecheap API and updates IP on your listed hosts with the IP of the calling machine.
Clone project:
git clone https://github.com/dcorral3/server_ip_utils.git
Set environment variables:
export DNS_DOMAIN_NAME=<example.com>
export DNS_PASSWORD=<password> # !! Sensitive information
export DNS_UPDATE_INTERVAL=<number | Default=15> # minutes to repeat script execution.
Tutorial for finding DNS_PASSWORD here
- Go to the downloaded folder:
cd server_ip_utils
- Execute script
./check_ip
Done!
The script will generate logs and last_ip files.
logs file will store the response of the curl command.
last_ip file will store the last IP for comparison.
Note: that you might also execute this as a cronjob using crontab.
More about crontab.
Do not be afraid of submitting pull requests to me. Happy to learn from you all =D.
- Diego del Corral - Initial work - dcorral3
What?