{"id":26713632,"url":"https://github.com/kryptobaseddev/duckdns-ddns","last_synced_at":"2025-03-27T12:29:42.711Z","repository":{"id":255969410,"uuid":"854003942","full_name":"kryptobaseddev/duckdns-ddns","owner":"kryptobaseddev","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-08T16:31:02.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-09T07:37:02.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kryptobaseddev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T06:14:31.000Z","updated_at":"2024-09-08T16:31:05.000Z","dependencies_parsed_at":"2024-09-08T07:45:52.463Z","dependency_job_id":null,"html_url":"https://github.com/kryptobaseddev/duckdns-ddns","commit_stats":null,"previous_names":["kryptobaseddev/duckdns-ddns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kryptobaseddev%2Fduckdns-ddns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kryptobaseddev%2Fduckdns-ddns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kryptobaseddev%2Fduckdns-ddns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kryptobaseddev%2Fduckdns-ddns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kryptobaseddev","download_url":"https://codeload.github.com/kryptobaseddev/duckdns-ddns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844450,"owners_count":20681712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-27T12:29:41.331Z","updated_at":"2025-03-27T12:29:42.701Z","avatar_url":"https://github.com/kryptobaseddev.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DuckDNS Updater\r\n\r\nThis package will automatically update your DuckDNS domain with the current IP address of your Raspberry Pi. It’s designed to run as a service that starts on boot and regularly checks every 5 minutes to ensure the external IP is updated.\r\n\r\n### Prerequisites\r\n\r\n1. **Ensure your Raspberry Pi is connected to the internet** and has access to the terminal (either directly or via SSH).\r\n\r\n2. **Install Git on your Raspberry Pi** (if it isn’t already installed). Run:\r\n    ```bash\r\n    sudo apt update\r\n    sudo apt install git\r\n    ```\r\n\r\n### 1. SSH Into Your Raspberry Pi\r\n\r\nIf you are connecting to your Raspberry Pi from another computer, follow these steps to use SSH (Secure Shell).\r\n\r\n#### A. **Enable SSH on the Raspberry Pi**\r\n- If you haven’t enabled SSH yet, follow these steps:\r\n    - Open the terminal on your Raspberry Pi or access it via a connected monitor and keyboard.\r\n    - Run the following commands to enable SSH:\r\n      ```bash\r\n      sudo systemctl enable ssh\r\n      sudo systemctl start ssh\r\n      ```\r\n\r\n#### B. **Find Your Raspberry Pi’s IP Address**\r\n- Run this command to find the IP address of your Raspberry Pi:\r\n    ```bash\r\n    hostname -I\r\n    ```\r\n- Note down the IP address (it will look like `192.168.x.xxx`).\r\n\r\n#### C. **SSH from Another Computer**\r\n- Open the terminal on your other computer (or PuTTY if you’re on Windows).\r\n- Use the following command, replacing `\u003craspberry-pi-ip\u003e` with your Raspberry Pi’s IP address:\r\n    ```bash\r\n    ssh pi@\u003craspberry-pi-ip\u003e\r\n    ```\r\n- Example: If your Pi’s IP is `192.168.1.100`, you’d run:\r\n    ```bash\r\n    ssh pi@192.168.1.100\r\n    ```\r\n- If this is your first time connecting, it will ask you to confirm the connection. Type `yes` and press Enter.\r\n- Enter the password (default is `raspberry`, unless you’ve changed it).\r\n\r\n### 2. Clone the DuckDNS Updater Repository\r\n\r\nOnce connected to your Raspberry Pi via SSH, you can clone the DuckDNS updater repository.\r\n\r\n1. Run the following commands:\r\n    ```bash\r\n    git clone https://github.com/kryptobaseddev/duckdns-ddns.git\r\n    cd duckdns-ddns\r\n    ```\r\n\r\nThis will download the repository and switch to the `duckdns-ddns` directory.\r\n\r\n### 3. Prepare the `duck.sh` Script\r\n\r\nThe `duck.sh` script is used to update DuckDNS with your Raspberry Pi's external IP.\r\n\r\n1. Make the `duck.sh` script executable by running the following command:\r\n    ```bash\r\n    chmod +x duck.sh\r\n    ```\r\n\r\n2. **Verify** that the `duck.sh` script is using the **hardcoded** DuckDNS domain and token (for now):\r\n    ```bash\r\n    nano duck.sh\r\n    ```\r\n\r\n    Ensure it looks something like this:\r\n\r\n    ```bash\r\n    #!/bin/bash\r\n\r\n    # Perform the DuckDNS update\r\n    echo \"Updating DuckDNS for domain yourdomain\"\r\n    curl \"https://www.duckdns.org/update?domains=yourdomain\u0026token=6f247643-your-token-953bfe70a016\u0026ip=\" -k -o ~/duckdns-ddns/duckdns.log\r\n\r\n    # Log the result\r\n    echo \"DuckDNS update complete. Log available at ~/duckdns-ddns/duckdns.log\"\r\n    ```\r\n\r\n    Once confirmed, save the file (`CTRL + X`, then `Y`, and `Enter`).\r\n\r\n### 4. Install the Service\r\n\r\nWe will now install the DuckDNS updater as a systemd service so it runs on boot.\r\n\r\n1. Copy the service file to the systemd folder:\r\n    ```bash\r\n    sudo cp duckdns.service /etc/systemd/system/\r\n    ```\r\n\r\n2. Reload the systemd daemon to recognize the new service:\r\n    ```bash\r\n    sudo systemctl daemon-reload\r\n    ```\r\n\r\n3. Enable the service to start automatically on boot:\r\n    ```bash\r\n    sudo systemctl enable duckdns.service\r\n    ```\r\n\r\n4. Start the DuckDNS service manually for the first time:\r\n    ```bash\r\n    sudo systemctl start duckdns.service\r\n    ```\r\n\r\nTo check the status of the service at any time, you can use:\r\n    ```bash\r\n    sudo systemctl status duckdns.service\r\n    ```\r\n\r\n### 5. (Optional) Install a Timer for Scheduled Updates\r\n\r\nIf you prefer to use a systemd timer instead of cron for updating your IP every 5 minutes, you can set up a timer.\r\n\r\n1. Copy the timer file to the systemd folder:\r\n    ```bash\r\n    sudo cp duckdns.timer /etc/systemd/system/\r\n    ```\r\n\r\n2. Reload the systemd daemon:\r\n    ```bash\r\n    sudo systemctl daemon-reload\r\n    ```\r\n\r\n3. Enable the timer to start on boot:\r\n    ```bash\r\n    sudo systemctl enable duckdns.timer\r\n    ```\r\n\r\n4. Start the timer:\r\n    ```bash\r\n    sudo systemctl start duckdns.timer\r\n    ```\r\n\r\nThis will ensure the DuckDNS updater runs every 5 minutes to check and update the external IP address.\r\n\r\n### 6. Configure Router for Remote Access\r\n\r\nTo access your Raspberry Pi from outside your local network (e.g., from the internet), you will need to set up port forwarding on your router.\r\n\r\n#### A. Access Your Router Settings\r\n- Open a browser and enter your router’s IP address (usually `192.168.1.1` or `192.168.0.1`).\r\n- Log in with your router’s credentials.\r\n\r\n#### B. Set Up Port Forwarding\r\n1. Find the **Port Forwarding** section in your router's settings (it may be under “Advanced” or “NAT”).\r\n2. Add a new forwarding rule:\r\n   - **External Port**: Choose a port for accessing your Pi remotely (e.g., 8080 for HTTP, 22 for SSH).\r\n   - **Internal IP Address**: Enter your Pi’s local IP (e.g., `192.168.1.100`).\r\n   - **Internal Port**: Match the internal port with the external one (e.g., 80 for HTTP or 22 for SSH).\r\n   - **Protocol**: Select `TCP` or `Both`.\r\n\r\n#### C. Save Changes\r\nAfter configuring the port forwarding, save the settings. You can now access your Pi from anywhere using your DuckDNS domain (e.g., `yourdomain.duckdns.org:8080` or `yourdomain.duckdns.org:22`).\r\n\r\n### 7. Testing Remote Access\r\nTo test if everything is working, try accessing your Raspberry Pi from outside your network using your DuckDNS domain. If you’ve forwarded SSH (port 22), for example:\r\n\r\n    ```bash\r\n    ssh pi@yourdomain.duckdns.org -p 22\r\n    ```\r\n\r\n---\r\n\r\n### 8. How to Set a Static IP on Raspberry Pi\r\n\r\nTo ensure your Raspberry Pi keeps the same IP address on your network, you can configure a static IP address by editing the `dhcpcd.conf` file.\r\n\r\n#### A. **Find the Current Network Information**\r\nFirst, get your current network details by running:\r\n```bash\r\nip addr show\r\n```\r\n\r\n#### B. **Edit the `dhcpcd.conf` File**\r\n1. Open the `dhcpcd.conf` file for editing:\r\n    ```bash\r\n    sudo nano /etc/dhcpcd.conf\r\n    ```\r\n2. Scroll to the bottom of the file and add the following lines, replacing the values with your desired static IP, router IP (gateway), and DNS server:\r\n    ```bash\r\n    interface wlan0  # For Wi-Fi (use eth0 for Ethernet)\r\n    static ip_address=10.0.0.138/24  # Your desired static IP and subnet mask\r\n    static routers=10.0.0.1  # Your router's IP (gateway)\r\n    static domain_name_servers=8.8.8.8 8.8.4.4  # Google's DNS or your preferred DNS\r\n    ```\r\n3. Save the file (`CTRL + X`, then `Y`, and `Enter`).\r\n\r\n#### C. **Restart the Raspberry Pi**\r\n- After saving the changes, restart your Raspberry Pi for the new static IP to take effect:\r\n    ```bash\r\n    sudo reboot\r\n    ```\r\n\r\n### D. Verify the Static IP\r\n- After the Pi reboots, check if the static IP is set correctly by running:\r\n    ```bash\r\n    ip addr show\r\n    ```\r\n\r\n## Troubleshooting\r\n- **Git Not Installed:** If you receive a “git command not found” error, install Git using the commands provided in the prerequisites section.\r\n    - Install Git using the following commands:\r\n        ```bash\r\n        sudo apt update\r\n        sudo apt install git\r\n        ```\r\n- **Permission Denied:** If you receive a “Permission Denied” error while running the `chmod +x duck.sh` command, ensure you’re running it with `sudo`.\r\n- **SSH Permission Denied:** If you receive a \"Permission Denied\" error while trying to SSH into the Pi, double-check the IP address and credentials. Ensure that SSH is enabled and the correct password is being used.\r\n    - You can enable SSH alternatively by creating an empty file named `ssh` in the boot partition of the SD card.\r\n        - Once the file is created, insert the SD card back into the Pi and boot it up.\r\n        - SSH should now be enabled, and you can connect to the Pi using the default credentials.\r\n        - Remember to change the default password for security reasons.\r\n        - If you need to keep SSH enabled, you can now run the `sudo systemctl enable ssh` command to ensure it starts on boot.\r\n    - If you’ve set up a static IP, ensure you’re using the correct IP address to connect.\r\n    - If you’re still unable to connect, try connecting via the local network first to troubleshoot.\r\n    - If you’re using a firewall, ensure that the port you’re trying to connect to is open.\r\n    - If you’re using a VPN, ensure that the VPN is not blocking the connection.\r\n    - If you’re using a public Wi-Fi network, ensure that the network allows SSH connections.\r\n\r\n## Future Improvements\r\n- **Dynamic Domain and Token:** Implement a way to pass the DuckDNS domain and token as arguments to the script for better security using the `config.env` file.\r\n- **Logging and Error Handling:** Add more detailed logging and error handling to the script for better troubleshooting.\r\n- **User Input Validation:** Validate user input for the DuckDNS domain and token to prevent incorrect entries.\r\n- **Custom Update Interval:** Allow users to set a custom update interval for the DuckDNS updater service.\r\n- **Secure Communication:** Implement secure communication between the Raspberry Pi and DuckDNS for updating the IP address.\r\n- **Web Interface:** Create a simple web interface to configure the DuckDNS updater settings and view logs.\r\n- **Email Notifications:** Add email notifications for successful or failed IP updates to keep users informed.\r\n- **Backup and Restore:** Implement a backup and restore feature for the DuckDNS updater settings and logs.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkryptobaseddev%2Fduckdns-ddns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkryptobaseddev%2Fduckdns-ddns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkryptobaseddev%2Fduckdns-ddns/lists"}