GithubHelp home page GithubHelp logo

navilg / namecheap-ddns-docker Goto Github PK

View Code? Open in Web Editor NEW
21.0 1.0 6.0 24 KB

Dynamic DNS client for namecheap

License: MIT License

Go 83.44% Dockerfile 8.69% Shell 7.87%
ddns ddns-client dynamic-dns domain namecheap

namecheap-ddns-docker's Introduction

Namecheap DDNS docker client

When to use ?

If your server do not have static IP, i.e. When Public IP of your server / router keep changing, This will automatically update new IP to Namecheap record.

Why to use it ?

  • Easy to setup

  • Lightweight

  • No cronjob configuration required

  • Logs for visibility

  • Open source

How to use it

  • Change nameserver of you domain to BasicDNS or PremiumDNS or FreeDNS. Namecheap Account -> Domain List -> Manage -> Domain -> NAMESERVERS -> Choose BasicDNS from dropdown

  • Enable Dynamic DNS for your domain from Namecheap. Namecheap Account -> Domain List -> Manage -> Advanced DNS -> Dynamic DNS -> Toggle Status

  • Copy the Dynamic DNS password which is generated after enabling Dynamic DNS. Keep it safe and handy.

  • Add a record of type A + Dynamic DNS with required host name.

  • Install docker on server.

  • Run below command

Suppose, You need DDNS for server.example.com

docker run --name server.example.com -d --restart unless-stopped -e NC_HOST='server' -e NC_DOMAIN='example.com' -e NC_PASS='DynamicDDNSPa2w0rd' linuxshots/namecheap-ddns

Here, NC_HOST is host name added in Namecheap record.

NC_DOMAIN is your domain name.

NC_PASS is your Dynamic DDNS password which is generated from Namecheap.

  • Check the log
docker logs server.example.com
  • To stop, start and remove DDNS.
docker stop server.example.com # To stop
docker start server.example.com # To start after its stopped
docker rm server.example.com -f # To remove

Build your own image

To build your own image

  • Clone this repo

  • Run docker build

# Replace OS and ARCH values with valid values of GOlang environment variables GOOS and GOARCH.
docker build --build-arg VERSION=1.0.0 -t linuxshots/namecheap-ddns . 

NOTE: This sets the TTL to Automatic i.e. 30 minutes. Currently, There is no way provided by Namecheap to set custom TTL in Dynamic DDNS.

namecheap-ddns-docker's People

Contributors

navilg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

namecheap-ddns-docker's Issues

Timeout the pubIp env variable set in container

Currently when IP address is set in namecheap, ncddns sets an env variable in current container so that it can compare the next time with current public IP. It prints the message "DNS record is same as current IP" if current public IP and env variable set is same.

This may not work if someone changes the IP address of a dns from namecheap dashboard unless container is restarted again. To avoid this, We can have a timeout set for env variable set, after which it should be wiped out so that fresh attempt to add ip address is made by ncddns.

Wrong requests contain error message and return status code 200

I've noticed the following code:

// req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*")
	// req.Header.Add("Accept-Encoding", "gzip, deflate, br")
	// req.Header.Add("Connection", "keep-alive")

	response, err := apiclient.Do(req)
	if err != nil {
		// fmt.Println(2, err.Error())
		return err
	}

	defer response.Body.Close()

	if response.StatusCode != 200 {
		return &CustomError{ErrorCode: response.StatusCode, Err: errors.New(response.Status)}
	}

It expects to have a HTTP status different than 200 when having an error. Yet, that's not the case. They are sending a XML payload with the error under 200.

<?xml version="1.0" encoding="utf-16"?>
<interface-response>
  <Command>SETDNSHOST</Command>
  <Language>eng</Language>
  <ErrCount>1</ErrCount>
  <errors>
    <Err1>Passwords do not match</Err1>
  </errors>
  <ResponseCount>1</ResponseCount>
  <responses>
    <response>
      <Description>Passwords do not match</Description>
      <ResponseNumber>304156</ResponseNumber>
      <ResponseString>Validation error; invalid ; password</ResponseString>
    </response>
  </responses>
  <Done>true</Done>
  <debug><![CDATA[]]></debug>
</interface-response>

Being able to parse this would help logging.

Feature request: Multiple hosts

I have a few subdomains all pointing to my homelab. It would be useful if I could provide multiple hosts, and update them all at once.

For example:

docker run --name server.example.com -d --restart unless-stopped -e NC_HOST='server,another,third' -e NC_DOMAIN='example.com' -e NC_PASS='DynamicDDNSPa2w0rd' linuxshots/namecheap-ddns

and the expected result is that server.example.com, another.example.com and third.example.com should now point to my current IP. My workaround for now is to run 5-6 copies, but this calls getPubIP more than necessary.

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.