Giter VIP home page Giter VIP logo

porkbun-ddns's Introduction

DNS Update Script

This script updates DNS records for a specified domain using the Porkbun API. It retrieves the current public IP address, compares it with the existing DNS records, and updates them if necessary.

Setup

  1. Clone the Repository:
  git clone https://github.com/clertonraf/porkbun-ddns.git
  cd porkbun-ddns
  1. Create a configuration file named config.conf with the following format
apikey=pk1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
secretapikey=sk1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
domain=example.com
  1. Execute the following command to run the script
./dns_update.sh

To run the script without updating the DNS records, use the --dry-run option:

./dns_update.sh --dry-run

Please note that the --dry-run option is not applicable when running the script as a systemd service.

systemd Service

You can set up the script as a systemd service to run it automatically. Here's how:

  1. Create a systemd service unit file
sudo nano /etc/systemd/system/dns_update.service

Add the following content to the file:

[Unit]
Description=DNS Update Script

[Service]
Type=simple
ExecStart=/path/to/your/script/dns_update.sh

[Install]
WantedBy=multi-user.target

Replace /path/to/your/script/ with the actual path where your script dns_update.sh is located.

  1. Enable and Start the Service

After saving the changes to dns_update.service, enable and start the service using the following commands

sudo systemctl daemon-reload
sudo systemctl enable dns_update.service
sudo systemctl start dns_update.service
  1. Verify the Service Status

You can verify that your service is running properly by checking its status

sudo systemctl status dns_update
  1. Schedule the Service to Run Every Hour You can use systemd's timer functionality to schedule the service to run every hour. Create a timer unit file named dns_update.timer in the same directory as your service unit file:
sudo nano /etc/systemd/system/dns_update.timer

Add the following content to the file:

[Unit]
Description=Run DNS Update Script Every Hour

[Timer]
OnCalendar=*-*-* *:00:00
Persistent=true

[Install]
WantedBy=timers.target

This configuration will run the service every hour at the beginning of the hour

  1. Enable and Start the Timer

After saving the changes to dns_update.timer, enable and start the timer:

sudo systemctl daemon-reload
sudo systemctl enable dns_update.timer
sudo systemctl start dns_update.timer

Troubleshooting

  • Permission Errors: Ensure that the script has the necessary permissions to access and modify the DNS records and log files. You may need to adjust file permissions or run the script with elevated privileges.
  • Failure to Update DNS Records: Check the log file for any error messages or debug information. Verify that the API credentials and domain information in the config.conf file are correct.

porkbun-ddns's People

Contributors

clertonraf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.