simple script to update all IPv4 or IPv6 for one domain hosted by netcup
ONLY UPDATING. No adding, deleting, creating, changing names, ...
Using the Netcup-DNS_API
Copy the file to your preferred folder.
Fill out your data:
- ncid=yourID
- apikey=yourapikey
- apipw=yourapipw
Your preferred Server:
- aip4a=$(curl -s 'https://ip4.first.de')
- aip4b=$(curl -s 'https://ip4.decond.de')
- aip6a=$(curl -s 'https://ip6.first.de')
- aip6b=$(curl -s 'https://ip6.second.de')
At first start:
cip4.log or/and cip6.log files for saving current ip addresses are created in the install folder.
At start-up before login:
an ip check compares the current and the stored ip.
If nothing has changed, the script will abort.
The script starts if ip changed or option -f is set.
Use Argument -U as single or like -dU, -dfU:
Option | Mode | description |
---|---|---|
-d | Debug | shows Informations |
-f | Force | ignores ip check and changes different ip's |
-U | Main function | checks and updates if ip's are different |
-i | Info | shows Informations about Domain |
-h | Help | shows Options and Examples |
Examples:
./dncapi.sh -U example.com A
./dncapi.sh -dU example.com AAAA
./dncapi.sh -fU example.com A
./dncapi.sh -dfU example.com AAAA
./dncapi.sh -i example.com A
Example outputs for IPv4:
1. Cronjob
-
0,30 * * * * /your path to/dncapi.sh -U example.de AAAA
- Using in cronjob:
- --> if NO Error or Update
- --> debug and force not activated
- there is no Output
- Using in cronjob:
2. Output (debug -d with force -f)
- force ignores ipcheck:
- --> is something to do changes are made
- debug prints some (login)informations
user@xxxx:~# ./dncapi.sh -dfU example.de A
Your choice: Domain --> example.de
IPv4 --> A
Server-1 IP: 177.198.122.123
Cached IPv4: 177.198.122.123
Your IPv4 for example.de has changed or -f --> force is enabled
Login successful
Session ID: NTE5NG5VSzM3ODYyMXZBbW9IY123456789123452eFo5Nz
Hostnames: * @ xxxx yyyy
--> force: Domain Zone Info
----------------------------------------------------------------------------------------------------
| ID | HostName | Stored IP | Public IP | Status |
----------------------------------------------------------------------------------------------------
| 44433344 | * | 177.198.122.123 | 177.198.122.123 | equal |
| 44433355 | @ | 177.198.122.123 | 177.198.122.123 | equal |
| 44433366 | xxxx | 199.198.199.123 | 177.198.122.123 | changed |
| 43355566 | yyyy | 177.198.122.123 | 177.198.122.123 | equal |
----------------------------------------------------------------------------------------------------
<-- force
Logout successful
3. Output (info -i)
- debug and force are activated automatically
- --> but no changes are made
- --> only info
user@xxxx:~# ./dncapi.sh -i example.de A
Your choice: Domain --> example.de
IPv4 --> A
Server-1 IP: 177.198.122.123
Cached IPv4: 177.198.122.123
Information about "--> example.de <--"
Login successful
Session ID: NTE5NG5VSzM3ODYyMXZBbW9IY123456789123452eFo5Nz
--------------------------------------------------------------------------------
| ID | Name | Type | IP |
--------------------------------------------------------------------------------
| 44433344 | * | A | 177.198.122.123 |
| 44433355 | @ | A | 177.198.122.123 |
| 44433366 | xxxx | A | 177.198.122.123 |
| 43355566 | yyyy | A | 177.198.122.123 |
--------------------------------------------------------------------------------
Logout successful