1
0

update README

This commit is contained in:
Chris Dzombak 2019-09-26 13:45:03 -04:00
parent 7e236a7cf0
commit bf919c063b
No known key found for this signature in database
GPG Key ID: 18A9AB4B8C54123A

View File

@ -1,7 +1,7 @@
# DIGITAL OCEAN DYNAMIC IP API CLIENT # DIGITAL OCEAN DYNAMIC IP API CLIENT
A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc. A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc.
To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. (These URLs can be customized; see Usage, below.)
## Requirements ## Requirements
Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building. Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building.
@ -18,9 +18,11 @@ Once the module is fetched, you should be able to compile the program using `go
## Usage ## Usage
```bash ```bash
# clone the repo in ~/go/src/github.com/anaganisk:
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
``` ```
create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and place it user home directory and add the following json
Create a file `.digitalocean-dynamic-ip.json` (dot prefix to hide the file) and place it in your home directory. Add the following JSON (or refer to the sample configuration file, `digitalocean-dynamic-ip.sample.json`):
```json ```json
{ {
@ -29,6 +31,7 @@ create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and
"useIPv4": true, "useIPv4": true,
"useIPv6": false, "useIPv6": false,
"allowIPv4InIPv6": false, "allowIPv4InIPv6": false,
"ipv4CheckUrl": "https://ipv4bot.whatismyipaddress.com",
"domains": [ "domains": [
{ {
"domain": "example.com", "domain": "example.com",
@ -52,6 +55,7 @@ create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and
] ]
} }
``` ```
The TTL can optionally be updated if passed in the configuration. Digital Ocean has a minimum TTL of 30 seconds. The `type` and the `name` must match existing records in the Digital Ocean DNS configuration. Only `types` of `A` and `AAAA` allowed at the moment. The TTL can optionally be updated if passed in the configuration. Digital Ocean has a minimum TTL of 30 seconds. The `type` and the `name` must match existing records in the Digital Ocean DNS configuration. Only `types` of `A` and `AAAA` allowed at the moment.
If you want to reduce the number of calls made to the digital ocean API and have more than 20 DNS records in your domain, you can adjust the `doPageSize` parameter. By default, Digital Ocean returns 20 records per page. Digital Ocean has a max page size of 200 items. If you want to reduce the number of calls made to the digital ocean API and have more than 20 DNS records in your domain, you can adjust the `doPageSize` parameter. By default, Digital Ocean returns 20 records per page. Digital Ocean has a max page size of 200 items.
@ -60,22 +64,25 @@ By default, the configuration checks both IPv4 and IPv6 addresses assuming your
The `allowIPv4InIPv6` configuration option will allow adding an IPv4 address to be used in a AAAA record for IPv6 lookups. The `allowIPv4InIPv6` configuration option will allow adding an IPv4 address to be used in a AAAA record for IPv6 lookups.
The `ipv4CheckUrl` and `ipv6CheckUrl` configuration settings are optional. If set, they must be URLs which respond to a GET request, with a plaintext response containing only your IP address. If unset, they default to `https://ipv_bot.whatismyipaddress.com`.
```bash ```bash
#run # after running `go build digitalocean-dynamic-ip.go`, run:
go build digitalocean-dynamic-ip.go
./digitalocean-dynamic-ip ./digitalocean-dynamic-ip
``` ```
Optionally, you can create the configuration file with any name wherever you want, and pass it as a command line argument: Optionally, you can create the configuration file with any name wherever you want, and pass it as a command line argument:
```bash ```bash
#run #run:
./digitalocean-dynamic-ip /path/to/my/config.json ./digitalocean-dynamic-ip /path/to/my/config.json
``` ```
You can either set this to run periodically with a cronjob or use your own method. You can either set this to run periodically with a cronjob or use your own method.
```bash ```bash
# run crontab -e # run `crontab -e` to edit your crontab
# sample cron job task # sample cron job task
# m h dom mon dow command # m h dom mon dow command
*/5 * * * * /home/user/digitalocean-dynamic-dns-ip/digitalocean-dynamic-ip */5 * * * * /home/user/digitalocean-dynamic-dns-ip/digitalocean-dynamic-ip