diff options
| author | Christian Cleberg <[email protected]> | 2025-11-11 22:49:13 -0600 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2025-11-11 22:49:13 -0600 |
| commit | 51a7a02f0c96d49b68fbcc155414c218207fa270 (patch) | |
| tree | 845af8aad0e8769352efc02fcd1044eed9cc1ec1 /content/blog/2022-02-10-njalla-dns-api.org | |
| parent | 7d3e80ebf1dc770eac0e21890b74f18ba2d15a6b (diff) | |
| download | cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.tar.gz cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.tar.bz2 cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.zip | |
fix grammar in 2022 posts
Diffstat (limited to 'content/blog/2022-02-10-njalla-dns-api.org')
| -rw-r--r-- | content/blog/2022-02-10-njalla-dns-api.org | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/content/blog/2022-02-10-njalla-dns-api.org b/content/blog/2022-02-10-njalla-dns-api.org index 7511368..ab233c9 100644 --- a/content/blog/2022-02-10-njalla-dns-api.org +++ b/content/blog/2022-02-10-njalla-dns-api.org @@ -5,47 +5,43 @@ * Njalla's API -As noted in my recent post about -[[https://cleberg.net/blog/ditching-cloudflare/][switching to Njalla from -Cloudflare]], I was searching for a way to replace my very easy-to-use -bash script to [[https://cleberg.net/blog/cloudflare-dns-api/][update Cloudflare's -DNS via their API]]. +As noted in my recent post about [[https://cleberg.net/blog/ditching-cloudflare/][switching to Njalla from Cloudflare]], I was +searching for a way to replace my [[https://cleberg.net/blog/cloudflare-dns-api.html][bash script]] to update my domain's =A= record +with my home's internet protocol (IP) address dynamically. -To reiterate what I said in those posts, this is a common necessity for -those of us who have non-static IP addresses that can change at any -moment due to ISP policy. +To reiterate what I said in those posts, this is a common necessity for those of +us who have non-static IP addresses that can change at any moment due to +internet service provider (ISP) policy. -In order to keep a home server running smoothly, the server admin needs -to have a process to constantly monitor their public IP address and -update their domain's DNS records if it changes. +In order to keep a home server running smoothly, the server admin needs to have +a process to constantly monitor their public IP address and update their +domain's DNS records if it changes. -This post explains how to use Python to update Njalla's DNS records -whenever a machine's public IP address changes. +This post explains how to use Python to update Njalla's DNS (domain name system) +records whenever a machine's public IP address changes. ** Creating a Token -To use Njalla's API, you will first need to create a token that will be -used to authenticate you every time you call the API. Luckily, this is -very easy to do if you have an account with Njalla. +To use Njalla's API, you will first need to create a token that will be used to +authenticate you every time you call the API (application programming +interface). Luckily, this is very easy to do if you have an account with Njalla. -Simply go the [[https://njal.la/settings/api/][API Settings]] page and -click the =Add Token= button. Next, enter a name for the token and click -=Add=. +Simply go the [[https://njal.la/settings/api/][API Settings]] page and click the =Add Token= button. Next, enter a +name for the token and click =Add=. -Finally, click the =Manage= button next to your newly created token and -copy the =API Token= field. +Finally, click the =Manage= button next to your newly created token and copy the +=API Token= field. ** Finding the Correct API Request -Once you have a token, you're ready to call the Njalla API for any -number of requests. For a full listing of available requests, see the -[[https://njal.la/api/][Njalla API Documentation]]. +Once you have a token, you're ready to call the Njalla API for any number of +requests. For a full listing of available requests, see the [[https://njal.la/api/][Njalla API +Documentation]]. -For this demo, we are using the =list-records= and =edit-record= -requests. +For this demo, we are using the =list-records= and =edit-record= requests. -The =list-records= request requires the following payload to be sent -when calling the API: +The =list-records= request requires the following payload to be sent when +calling the API: #+begin_src txt params: { @@ -53,8 +49,8 @@ params: { } #+end_src -The =edit-record= request requires the following payload to be sent when -calling the API: +The =edit-record= request requires the following payload to be sent when calling +the API: #+begin_src txt params: { @@ -66,14 +62,14 @@ params: { * Server Set-Up -To create this script, we will be using Python. By default, I use Python -3 on my servers, so please note that I did not test this in Python 2, -and I do not know if Python 2 will work for this. +To create this script, we will be using Python. By default, I use Python 3 on my +servers, so please note that I did not test this in Python 2, and I do not know +if Python 2 will work for this. ** Creating the Script -First, find a suitable place to create your script. Personally, I just -create a directory called =ddns= in my home directory: +First, find a suitable place to create your script. Personally, I just create a +directory called =ddns= in my home directory: #+begin_src sh mkdir ~/ddns @@ -85,20 +81,18 @@ Next, create a Python script file: nano ~/ddns/ddns.py #+end_src -The following code snippet is quite long, so I won't go into depth on -each part. However, I suggest you read through the entire script before -running it; it is quite simple and contains comments to help explain -each code block. +The following code snippet is quite long, so I won't go into depth on each part. +However, I suggest you read through the entire script before running it; it is +quite simple and contains comments to help explain each code block. -:warning: *Note*: You will need to update the following variables for -this to work: +*Note*: You will need to update the following variables for this to work: - =token=: This is the Njalla API token you created earlier. - =user_domain=: This is the top-level domain you want to modify. -- =include_subdomains=: Set this to =True= if you also want to modify - subdomains found under the TLD. -- =subdomains=: If =include_subdomains= = =True=, you can include your - list of subdomains to be modified here. +- =include_subdomains=: Set this to =True= if you also want to modify subdomains + found under the TLD (top-level domain). +- =subdomains=: If =include_subdomains= = =True=, you can include your list of + subdomains to be modified here. #+begin_src python #!/usr/bin/python @@ -183,8 +177,8 @@ for record in data['records']: ** Running the Script -Once you've created the script and are ready to test it, run the -following command: +Once you've created the script and are ready to test it, run the following +command: #+begin_src sh python3 ~/ddns/ddns.py @@ -192,15 +186,15 @@ python3 ~/ddns/ddns.py ** Setting the Script to Run Automatically -To make sure the scripts run automatically, add it to the =cron= file so -that it will run on a schedule. To do this, open the =cron= file: +To make sure the scripts run automatically, add it to the =cron= file so that it +will run on a schedule. To do this, open the =cron= file: #+begin_src sh crontab -e #+end_src -In the cron file, paste the following at the bottom of the editor in -order to check the IP every five minutes: +In the cron file, paste the following at the bottom of the editor in order to +check the IP every five minutes: #+begin_src sh */5 * * * * python3 /home/<your_username>/ddns/ddns.py |
