Skip to content

Commit ee2cd26

Browse files
committed
Release version 4.0 of the dynamic DNS client for netcup DNS API
1 parent db59ea7 commit ee2cd26

File tree

5 files changed

+332
-228
lines changed

5 files changed

+332
-228
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
config.php
2+
.php-cs-fixer.cache

README.md

Lines changed: 11 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
### Implemented
1616
* All necessary API functions for DNS actions implemented (REST API)
1717
* Determines correct public IP address, uses fallback API for determining the IP address, in case main API does return invalid / no IP
18-
* IPv6 Support
18+
* Automatically retries API requests on errors
19+
* IPv4 and IPv6 Support (can be individually enabled / disabled)
20+
* Possible to manually provide IPv4 / IPv6 address to set as a CLI option
1921
* Update everything you want in one go: Every combination of domains, subdomains, domain root, and domain wildcard is possible
2022
* Creation of DNS record, if it doesn't already exist
2123
* If configured, lowers TTL to 300 seconds for the domain on each run, if necessary
@@ -51,119 +53,13 @@ You should probably run this script every few minutes, so that your IP is update
5153
### CLI options
5254
Just add these Options after the command like `./update.php --quiet`
5355

54-
| option | function |
55-
| ------------- |----------------------------------------------------------:|
56-
| --quiet | The script won't output notices, only errors and warnings |
57-
58-
## Example outputs
59-
```
60-
$ ./update.php
61-
[2022/01/20 00:35:02 +0000][NOTICE] =============================================
62-
[2022/01/20 00:35:02 +0000][NOTICE] Running dynamic DNS client for netcup 3.0
63-
[2022/01/20 00:35:02 +0000][NOTICE] This script is not affiliated with netcup.
64-
[2022/01/20 00:35:02 +0000][NOTICE] =============================================
65-
66-
[2022/01/20 00:35:02 +0000][NOTICE] Logged in successfully!
67-
[2022/01/20 00:35:02 +0000][NOTICE] Updating DNS records for domain "myfirstdomain.com"
68-
[2022/01/20 00:35:03 +0000][NOTICE] Successfully received Domain info.
69-
[2022/01/20 00:35:03 +0000][NOTICE] Lowered TTL to 300 seconds successfully.
70-
[2022/01/20 00:35:03 +0000][NOTICE] Successfully received DNS record data.
71-
[2022/01/20 00:35:03 +0000][NOTICE] Updating DNS records for subdomain "subdomain1" of domain "myfirstdomain.com".
72-
[2022/01/20 00:35:03 +0000][NOTICE] A record for host subdomain1 doesn't exist, creating necessary DNS record.
73-
[2022/01/20 00:35:03 +0000][NOTICE] IPv4 address has changed. Before: newly created Record; Now: 5.6.7.8
74-
[2022/01/20 00:35:03 +0000][NOTICE] IPv4 address updated successfully!
75-
[2022/01/20 00:35:03 +0000][NOTICE] AAAA record for host subdomain1 doesn't exist, creating necessary DNS record.
76-
[2022/01/20 00:35:03 +0000][NOTICE] IPv6 address has changed. Before: newly created Record; Now: 2001:db8:85a3:0:0:8a2e:370:7334
77-
[2022/01/20 00:35:03 +0000][NOTICE] IPv6 address updated successfully!
78-
[2022/01/20 00:35:03 +0000][NOTICE] Updating DNS records for subdomain "subdomain2" of domain "myfirstdomain.com".
79-
[2022/01/20 00:35:03 +0000][NOTICE] A record for host subdomain2 doesn't exist, creating necessary DNS record.
80-
[2022/01/20 00:35:03 +0000][NOTICE] IPv4 address has changed. Before: newly created Record; Now: 5.6.7.8
81-
[2022/01/20 00:35:03 +0000][NOTICE] IPv4 address updated successfully!
82-
[2022/01/20 00:35:03 +0000][NOTICE] AAAA record for host subdomain2 doesn't exist, creating necessary DNS record.
83-
[2022/01/20 00:35:03 +0000][NOTICE] IPv6 address has changed. Before: newly created Record; Now: 2001:db8:85a3:0:0:8a2e:370:7334
84-
[2022/01/20 00:35:03 +0000][NOTICE] IPv6 address updated successfully!
85-
[2022/01/20 00:35:03 +0000][NOTICE] Updating DNS records for domain "myseconddomain.com"
86-
[2022/01/20 00:35:03 +0000][NOTICE] Successfully received Domain info.
87-
[2022/01/20 00:35:04 +0000][NOTICE] Successfully received DNS record data.
88-
[2022/01/20 00:35:04 +0000][NOTICE] Updating DNS records for subdomain "@" of domain "myseconddomain.com".
89-
[2022/01/20 00:35:04 +0000][NOTICE] A record for host @ doesn't exist, creating necessary DNS record.
90-
[2022/01/20 00:35:04 +0000][NOTICE] IPv4 address has changed. Before: newly created Record; Now: 5.6.7.8
91-
[2022/01/20 00:35:04 +0000][NOTICE] IPv4 address updated successfully!
92-
[2022/01/20 00:35:04 +0000][NOTICE] AAAA record for host @ doesn't exist, creating necessary DNS record.
93-
[2022/01/20 00:35:04 +0000][NOTICE] IPv6 address has changed. Before: newly created Record; Now: 2001:db8:85a3:0:0:8a2e:370:7334
94-
[2022/01/20 00:35:04 +0000][NOTICE] IPv6 address updated successfully!
95-
[2022/01/20 00:35:04 +0000][NOTICE] Updating DNS records for subdomain "*" of domain "myseconddomain.com".
96-
[2022/01/20 00:35:04 +0000][NOTICE] A record for host * doesn't exist, creating necessary DNS record.
97-
[2022/01/20 00:35:04 +0000][NOTICE] IPv4 address has changed. Before: newly created Record; Now: 5.6.7.8
98-
[2022/01/20 00:35:04 +0000][NOTICE] IPv4 address updated successfully!
99-
[2022/01/20 00:35:04 +0000][NOTICE] AAAA record for host * doesn't exist, creating necessary DNS record.
100-
[2022/01/20 00:35:04 +0000][NOTICE] IPv6 address has changed. Before: newly created Record; Now: 2001:db8:85a3:0:0:8a2e:370:7334
101-
[2022/01/20 00:35:04 +0000][NOTICE] IPv6 address updated successfully!
102-
[2022/01/20 00:35:04 +0000][NOTICE] Logged out successfully!
103-
```
104-
```
105-
$ ./update.php
106-
[2022/01/20 00:39:00 +0000][NOTICE] =============================================
107-
[2022/01/20 00:39:00 +0000][NOTICE] Running dynamic DNS client for netcup 3.0
108-
[2022/01/20 00:39:00 +0000][NOTICE] This script is not affiliated with netcup.
109-
[2022/01/20 00:39:00 +0000][NOTICE] =============================================
110-
111-
[2022/01/20 00:39:00 +0000][NOTICE] Logged in successfully!
112-
[2022/01/20 00:39:00 +0000][NOTICE] Updating DNS records for domain "myfirstdomain.com"
113-
[2022/01/20 00:39:00 +0000][NOTICE] Successfully received Domain info.
114-
[2022/01/20 00:39:00 +0000][NOTICE] Successfully received DNS record data.
115-
[2022/01/20 00:39:00 +0000][NOTICE] Updating DNS records for subdomain "subdomain1" of domain "myfirstdomain.com".
116-
[2022/01/20 00:39:00 +0000][NOTICE] IPv4 address hasn't changed. Current IPv4 address: 5.6.7.8
117-
[2022/01/20 00:39:00 +0000][NOTICE] IPv6 address hasn't changed. Current IPv6 address: 2001:db8:85a3:0:0:8a2e:370:7334
118-
[2022/01/20 00:39:00 +0000][NOTICE] Updating DNS records for subdomain "subdomain2" of domain "myfirstdomain.com".
119-
[2022/01/20 00:39:00 +0000][NOTICE] IPv4 address hasn't changed. Current IPv4 address: 5.6.7.8
120-
[2022/01/20 00:39:00 +0000][NOTICE] IPv6 address hasn't changed. Current IPv6 address: 2001:db8:85a3:0:0:8a2e:370:7334
121-
[2022/01/20 00:39:00 +0000][NOTICE] Updating DNS records for domain "myseconddomain.com"
122-
[2022/01/20 00:39:01 +0000][NOTICE] Successfully received Domain info.
123-
[2022/01/20 00:39:01 +0000][NOTICE] Successfully received DNS record data.
124-
[2022/01/20 00:39:01 +0000][NOTICE] Updating DNS records for subdomain "@" of domain "myseconddomain.com".
125-
[2022/01/20 00:39:01 +0000][NOTICE] IPv4 address hasn't changed. Current IPv4 address: 5.6.7.8
126-
[2022/01/20 00:39:01 +0000][NOTICE] IPv6 address hasn't changed. Current IPv6 address: 2001:db8:85a3:0:0:8a2e:370:7334
127-
[2022/01/20 00:39:01 +0000][NOTICE] Updating DNS records for subdomain "*" of domain "myseconddomain.com".
128-
[2022/01/20 00:39:01 +0000][NOTICE] IPv4 address hasn't changed. Current IPv4 address: 5.6.7.8
129-
[2022/01/20 00:39:01 +0000][NOTICE] IPv6 address hasn't changed. Current IPv6 address: 2001:db8:85a3:0:0:8a2e:370:7334
130-
[2022/01/20 00:39:01 +0000][NOTICE] Logged out successfully!
131-
```
132-
```
133-
$ ./update.php
134-
[2022/01/20 00:40:10 +0000][NOTICE] =============================================
135-
[2022/01/20 00:40:10 +0000][NOTICE] Running dynamic DNS client for netcup 3.0
136-
[2022/01/20 00:40:10 +0000][NOTICE] This script is not affiliated with netcup.
137-
[2022/01/20 00:40:10 +0000][NOTICE] =============================================
138-
139-
[2022/01/20 00:40:10 +0000][NOTICE] Logged in successfully!
140-
[2022/01/20 00:40:10 +0000][NOTICE] Updating DNS records for domain "myfirstdomain.com"
141-
[2022/01/20 00:40:10 +0000][NOTICE] Successfully received Domain info.
142-
[2022/01/20 00:40:10 +0000][NOTICE] Successfully received DNS record data.
143-
[2022/01/20 00:40:10 +0000][NOTICE] Updating DNS records for subdomain "subdomain1" of domain "myfirstdomain.com".
144-
[2022/01/20 00:40:10 +0000][NOTICE] IPv4 address has changed. Before: 5.6.7.8; Now: 1.2.3.4
145-
[2022/01/20 00:40:11 +0000][NOTICE] IPv4 address updated successfully!
146-
[2022/01/20 00:40:11 +0000][NOTICE] IPv6 address has changed. Before: 2001:db8:85a3:0:0:8a2e:370:7334; Now: 2001:db8:85a3:0:0:8a2e:370:5123
147-
[2022/01/20 00:40:11 +0000][NOTICE] IPv6 address updated successfully!
148-
[2022/01/20 00:40:11 +0000][NOTICE] Updating DNS records for subdomain "subdomain2" of domain "myfirstdomain.com".
149-
[2022/01/20 00:40:11 +0000][NOTICE] IPv4 address has changed. Before: 5.6.7.8; Now: 1.2.3.4
150-
[2022/01/20 00:40:11 +0000][NOTICE] IPv4 address updated successfully!
151-
[2022/01/20 00:40:11 +0000][NOTICE] IPv6 address has changed. Before: 2001:db8:85a3:0:0:8a2e:370:7334; Now: 2001:db8:85a3:0:0:8a2e:370:5123
152-
[2022/01/20 00:40:11 +0000][NOTICE] IPv6 address updated successfully!
153-
[2022/01/20 00:40:11 +0000][NOTICE] Updating DNS records for domain "myseconddomain.com"
154-
[2022/01/20 00:40:11 +0000][NOTICE] Successfully received Domain info.
155-
[2022/01/20 00:40:11 +0000][NOTICE] Successfully received DNS record data.
156-
[2022/01/20 00:40:11 +0000][NOTICE] Updating DNS records for subdomain "@" of domain "myseconddomain.com".
157-
[2022/01/20 00:40:11 +0000][NOTICE] IPv4 address has changed. Before: 5.6.7.8; Now: 1.2.3.4
158-
[2022/01/20 00:40:12 +0000][NOTICE] IPv4 address updated successfully!
159-
[2022/01/20 00:40:12 +0000][NOTICE] IPv6 address has changed. Before: 2001:db8:85a3:0:0:8a2e:370:7334; Now: 2001:db8:85a3:0:0:8a2e:370:5123
160-
[2022/01/20 00:40:12 +0000][NOTICE] IPv6 address updated successfully!
161-
[2022/01/20 00:40:12 +0000][NOTICE] Updating DNS records for subdomain "*" of domain "myseconddomain.com".
162-
[2022/01/20 00:40:12 +0000][NOTICE] IPv4 address has changed. Before: 5.6.7.8; Now: 1.2.3.4
163-
[2022/01/20 00:40:12 +0000][NOTICE] IPv4 address updated successfully!
164-
[2022/01/20 00:40:12 +0000][NOTICE] IPv6 address has changed. Before: 2001:db8:85a3:0:0:8a2e:370:7334; Now: 2001:db8:85a3:0:0:8a2e:370:5123
165-
[2022/01/20 00:40:12 +0000][NOTICE] IPv6 address updated successfully!
166-
[2022/01/20 00:40:12 +0000][NOTICE] Logged out successfully!
167-
```
56+
| short option | long option | function |
57+
| ------------ | ------------------ |----------------------------------------------------------:|
58+
| -q | --quiet | The script won't output notices, only errors and warnings |
59+
| -c | --config | Manually provide a path to the config file |
60+
| -4 | --ipv4 | Manually provide the IPv4 address to set |
61+
| -6 | --ipv6 | Manually provide the IPv6 address to set |
62+
| -h | --help | Outputs this help |
63+
| -v | --version | Outputs the current version of the script |
16864

16965
If you have ideas on how to improve this script, please don't hesitate to create an issue or provide me with a pull request. Thank you!

config.dist.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
// define('HOST', 'server');
2929

3030

31+
// If set to true, the script will check for your public IPv4 address and add it as an A-Record / change an existing A-Record for the host.
32+
// You may want to deactivate this, for example, when using a carrier grade NAT (CGNAT).
33+
// Most likely though, you should keep this active, unless you know otherwise.
34+
define('USE_IPV4', true);
35+
3136
// If set to true, the script will check for your public IPv6 address too and add it as an AAAA-Record / change an existing AAAA-Record for the host.
3237
// Activate this only if you have IPv6 connectivity, or you *WILL* get errors.
3338
define('USE_IPV6', false);

0 commit comments

Comments
 (0)