Unsure How to Configure DynamicDNS for Namecheap

1. The problem I’m having:

I tried getting DynamicDNS set up for Namecheap, but since I'm hosting on Linux and can't download their program, I don't know what to do. I figured the API would be responsible for it all, but I couldn't find any confirmation for it. So I guess this is more of a question overall.

2. Error messages and/or full log output:

This is the main error, but I'm starting to think that the DynamicDNS directives aren't going to help me here.
Error: adapting config using caddyfile: parsing caddyfile tokens for 'dynamic_dns': wrong argument count or unexpected line ending after 'REDACTED API KEY', at /etc/caddy/Caddyfile:3

3. Caddy version:

v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=

4. How I installed and ran Caddy:

xcaddy build --with github.com/caddy-dns/namecheap --with github.com/mholt/caddy-dynamicdns

a. System environment:

Arch Linux using Linux-LTS kernel, x86_64
Docker and Docker Compose

b. Service/unit/compose file:

I have only pasted the relevant information, which should be Caddy alone.
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp # Needed for HTTP/3.
    volumes:
      - /srv/caddy/caddy:/usr/bin/caddy  # Your custom build of Caddy.
      - /srv/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - /srv/caddy/caddy-config:/config
      - /srv/caddy/caddy-data:/data
    environment:
      EMAIL: "REDACTED"                 # The email address to use for ACME registration.
      LOG_FILE: "/data/access.log"
    extra_hosts: ["host.docker.internal:host-gateway"]
    networks:
      caddy_net: {}
      dns:
      vaultwarden_net:
      homeassistant_net:
      teamspeak_net:
      nextcloud_net:

networks:
  caddy_net:
    external: true
  dns:
    ipam:
      config:
        - subnet: 172.50.0.0/16
  vaultwarden_net:
  homeassistant_net:
  teamspeak_net:
  nextcloud_net:

c. My complete Caddy config:

{
        debug
}


{
        dynamic_dns {
                provider namecheap "REDACTED API KEY"
                domains {
                        famdam.top
                }
        }
}

*.famdam.top {

    tls {
        dns namecheap {
            api_key REDACTED
            user REDACTED
            api_endpoint https://api.namecheap.com/xml.response
            client_ip 139.60.65.236
        }
    }

        @vaultwarden host vaultwarden.famdam.top
        handle @vaultwarden {
            reverse_proxy vaultwarden:80
        }

        @wireguard host wireguard.famdam.top
        handle @wireguard {
            reverse_proxy wireguard:80
        }

        @pihole host pihole.famdam.top
        handle @pihole {
            reverse_proxy pihole:80
        }

#        @srv-teamspeak-1 host teamspeak.famdam.top
#        handle @srv-teamspeak-1 {
#            reverse_proxy 192.168.1.60:9987
#        }

        @nextcloud-aio-mastercontainer host nextcloud.famdam.top
        handle @nextcloud-aio-mastercontainer {
            reverse_proxy host.docker.internal:11000
        }

        # Fallback for otherwise unhandled domains
        handle {
                abort
        }


        # This setting may have compatibility issues with some browsers
        # (e.g., attachment downloading on Firefox). Try disabling this
        # if you encounter issues.
        encode zstd gzip

}

5. Links to relevant resources:

Sorry, not what you’re asking about, but it might help.

With NameCheap, you can easily update your dynamic DNS using curl.

Let’s say you have my-site.example.com defined in your NameCheap DNS as an A + Dynamic DNS Record. You can update it from your server with the following command:

curl "https://dynamicdns.park-your-domain.com/update?host=my-site&domain=example.com&password=DYNAMIC_DNS_PASSWORD"

Here, DYNAMIC_DNS_PASSWORD is the Dynamic DNS password you can find in your NameCheap portal.

To automate this, a simple cron job running the following:

curl -s "https://dynamicdns.park-your-domain.com/update?host=my-site&domain=example.com&password=DYNAMIC_DNS_PASSWORD" > /dev/null

will take care of it.

If you’d like to give it a try, you can find more details here:

1 Like