Giter Site home page Giter Site logo

timothyye / godns Goto Github PK

View Code? Open in Web Editor NEW
1.5K 35.0 218.0 2.35 MB

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.

Home Page: https://timothyye.github.io/godns/

License: Apache License 2.0

Go 69.00% Makefile 0.81% Dockerfile 0.36% TypeScript 29.72% CSS 0.03% JavaScript 0.09%
dns dnspod ddns dyndns dynamic-dns duckdns cloudflare alidns godns dreamhost

godns's Introduction

 ██████╗  ██████╗ ██████╗ ███╗   ██╗███████╗
██╔════╝ ██╔═══██╗██╔══██╗████╗  ██║██╔════╝
██║  ███╗██║   ██║██║  ██║██╔██╗ ██║███████╗
██║   ██║██║   ██║██║  ██║██║╚██╗██║╚════██║
╚██████╔╝╚██████╔╝██████╔╝██║ ╚████║███████║
 ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚══════╝

Apache licensed Docker Go Report Card Cover.Run GoDoc

GoDNS is a dynamic DNS (DDNS) client tool. It is a rewrite in Go of my early DynDNS open source project.



Supported DNS Providers

Provider IPv4 support IPv6 support Root Domain Subdomains
Cloudflare
DigitalOcean
Google Domains
DNSPod
Dynv6
HE.net (Hurricane Electric)
AliDNS
DuckDNS
Dreamhost
No-IP
Scaleway
Linode
Strato
LoopiaSE
Infomaniak
Hetzner
OVH
Dynu
IONOS

Tip: You can follow this issue to view the current status of DDNS for root domains.

Supported Platforms

  • Linux

  • MacOS

  • ARM Linux (Raspberry Pi, etc.)

  • Windows

  • MIPS32 platform

    To compile binaries for MIPS (mips or mipsle), run:

    GOOS=linux GOARCH=mips/mipsle GOMIPS=softfloat go build -a

    The binary can run on routers as well.

Pre-conditions

To use GoDNS, it is assumed:

  • You registered (now own) a domain
  • Domain was delegated to a supported DNS provider (i.e. it has nameserver NS records pointing at a supported provider)

Alternatively, you can sign in to DuckDNS (with a social account) and get a subdomain on the duckdns.org domain for free.

Installation

Build GoDNS by running (from the root of the repository):

cd cmd/godns        # go to the GoDNS directory
go mod download     # get dependencies
go build            # build

You can also download a compiled binary from the releases.

Usage

Print usage/help by running:

$ ./godns -h
Usage of ./godns:
  -c string
        Specify a config file (default "./config.json")
  -h    Show help

Configuration

Overview

  • Make a copy of config_sample.json and name it as config.json, or make a copy of config_sample.yaml and name it as config.yaml.
  • Configure your provider, domain/subdomain info, credentials, etc.
  • Configure a notification medium (e.g. SMTP to receive emails) to get notified when your IP address changes
  • Place the file in the same directory of GoDNS or use the -c=path/to/your/file.json option

Configuration file format

GoDNS supports 2 different configuration file formats:

  • JSON
  • YAML

By default, GoDNS uses JSON config file. However, you can specify to use the YAML format via: ./godns -c /path/to/config.yaml

Dynamic loading of configuration

GoDNS supports dynamic loading of configuration. If you modify the configuration file, GoDNS will automatically reload the configuration and apply the changes.

Configuration properties

  • provider — One of the supported provider to use: Cloudflare, Google, DNSPod, AliDNS, HE, DuckDNS or Dreamhost.
  • email — Email or account name of the DNS provider.
  • password — Password of the DNS provider.
  • login_token — API token of the DNS provider.
  • domains — Domains list, with your sub domains.
  • ip_urls — A URL array for fetching one's public IPv4 address.
  • ipv6_urls — A URL array for fetching one's public IPv6 address.
  • ip_type — Switch deciding if IPv4 or IPv6 should be used (when supported). Available values: IPv4 or IPv6.
  • interval — How often (in seconds) the public IP should be updated.
  • socks5_proxy — Socks5 proxy server.
  • resolver — Address of a public DNS server to use. For instance to use Google's public DNS, you can set 8.8.8.8 when using GoDNS in IPv4 mode or 2001:4860:4860::8888 in IPv6 mode.
  • skip_ssl_verify - Skip verification of ssl certificates for https requests.

Update root domain

By simply putting @ into sub_domains, for example:

"domains": [{
      "domain_name": "example.com",
      "sub_domains": ["@"]
    }]

Configuration examples

Cloudflare

For Cloudflare, you need to provide the email & Global API Key as password (or to use the API token) and config all the domains & subdomains.

By setting the option proxied = true, the record is receiving the performance and security benefits of Cloudflare. This option is only available for Cloudflare.

Using email & Global API Key
{
  "provider": "Cloudflare",
  "email": "[email protected]",
  "password": "Global API Key",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": "",
  "proxied": false
}
Using the API Token
{
  "provider": "Cloudflare",
  "login_token": "API Token",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

DNSPod

For DNSPod, you need to provide your API Token(you can create it here), and config all the domains & subdomains.

Example
{
  "provider": "DNSPod",
  "login_token": "your_id,your_token",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

DigitalOcean

For DigitalOcean, you need to provide a API Token with the domain scopes (you can create it here), and config all the domains & subdomains.

Example
{
  "provider": "DigitalOcean",
  "login_token": "dop_v1_00112233445566778899aabbccddeeff",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["@", "www"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300
}

Dreamhost

For Dreamhost, you need to provide your API Token(you can create it here), and config all the domains & subdomains.

Example
{
  "provider": "Dreamhost",
  "login_token": "your_api_key",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "resolver": "ns1.dreamhost.com",
  "socks5_proxy": ""
}

Dynv6

For Dynv6, only need to provide the token, config 1 default domain & subdomains.

Example
{
  "provider": "Dynv6",
  "password": "",
  "login_token": "1234567ABCDEFGabcdefg123456789",
  "domains": [
    {
      "domain_name": "dynv6.net",
      "sub_domains": ["myname"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

Google Domains

For Google Domains, you need to provide email & password, and config all the domains & subdomains.

Example
{
  "provider": "Google",
  "email": "Your_Username",
  "password": "Your_Password",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

AliDNS

For AliDNS, you need to provide AccessKeyID & AccessKeySecret as email & password, and config all the domains & subdomains.

Example
{
  "provider": "AliDNS",
  "email": "AccessKeyID",
  "password": "AccessKeySecret",
  "login_token": "",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

DuckDNS

For DuckDNS, the only thing needed is to provide the token, config 1 default domain & subdomains.

Example
{
  "provider": "DuckDNS",
  "password": "",
  "login_token": "3aaaaaaaa-f411-4198-a5dc-8381cac61b87",
  "domains": [
    {
      "domain_name": "www.duckdns.org",
      "sub_domains": ["myname"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

No-IP

Example
{
  "provider": "NoIP",
  "email": "[email protected]",
  "password": "YourPassword",
  "domains": [
    {
      "domain_name": "ddns.net",
      "sub_domains": ["timothyye6"]
    }
  ],
  "ip_type": "IPv4",
  "ip_urls": ["https://api.ip.sb/ip"],
  "resolver": "8.8.8.8",
  "interval": 300,
  "socks5_proxy": ""
}

HE.net

For HE, email is not needed, just fill the DDNS key as password, and config all the domains & subdomains.

Example
{
  "provider": "HE",
  "password": "Your DDNS Key",
  "login_token": "",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}
Provider configuration

Add a new "A record" and make sure that "Enable entry for dynamic dns" is checked:

Fill in your own DDNS key or generate a random DDNS key for this new created "A record":

Remember the DDNS key and set it in the password property in the configuration file.

NOTICE: If you have multiple domains or subdomains, make sure their DDNS key are the same.

Scaleway

For Scaleway, you need to provide an API Secret Key as the login_token (How to generate an API key), and configure the domains and subdomains. domain_name should equal a DNS zone, or the root domain in Scaleway. TTL for the DNS records will be set to the interval value. Make sure A or AAAA records exist for the relevant sub domains, these can be set up in the Scaleway console.

Example
{
  "provider": "Scaleway",
  "login_token": "API Secret Key",
  "domains": [{
      "domain_name": "example.com",
      "sub_domains": ["www","@"]
    },{
      "domain_name": "samplednszone.example.com",
      "sub_domains": ["www","test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300
}

Linode

To authenticate with the Linode API you will need to provide a Personal Access Token with "Read/Write" access on the "Domain" scope. Linode has a help page about creating access tokens. Pass this token into the login_token field of the config file.

The domain_name field of the config file must be the name of an existing Domain managed by Linode. Linode has a help page about adding domains. The GoDNS Linode handler will not create domains automatically, but will create subdomains automatically.

The GoDNS Linode handler currently uses a fixed TTL of 30 seconds for Linode DNS records.

Example
{
  "provider": "Linode",
  "login_token": ${PERSONAL_ACCESS_TOKEN},
  "domains": [{
      "domain_name": "example.com",
      "sub_domains": ["www","@"]
    },{
      "domain_name": "samplednszone.example.com",
      "sub_domains": ["www","test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300
}

Strato

For Strato, you need to provide email & password, and config all the domains & subdomains. More Info: German English

Example
{
  "provider": "strato",
  "password": "Your_Password",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

LoopiaSE

For LoopiaSE, you need to provide username & password, and config all the domains & subdomains. More info: Swedish

Example
{
  "provider": "LoopiaSE",
  "email": "Your_Username",
  "password": "Your_Password",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

Infomaniak

For Infomaniak, you need to provide username & password, and config all the domains & subdomains. More info: English

Example
{
  "provider": "Infomaniak",
  "email": "Your_Username",
  "password": "Your_Password",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

Hetzner

For Hetzner, you have to create an access token. This can be done in the DNS-Console. (Person Icon in the top left corner --> API Tokens) Notice: If a domain has multiple Records only the first Record will be updated. Make shure there is just one record.

Example
{
  "provider": "hetzner",
  "login_token": "<token>",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4"
}

OVH

For OVH, you need to provide a Consumerkey, an Appsecret, an Appkey and configure all the domains & subdomains. The neeeded values can be obtaines by visting this site Rights should be '*' on GET, POST and PUT More info: help.ovhcloud.com

Example
{
  "provider": "OVH",
  "consumer_key": "e389ac80cc8da9c7451bc7b8f171bf4f",
  "app_secret": "d1ffee354d3643d70deaab48a09131fd",
  "app_key": "cd338839d6472064",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["www", "test"]
    },
    {
      "domain_name": "example2.com",
      "sub_domains": ["www", "test"]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

Dynu

For Dynu, you need to configure the password, config 1 default domain & subdomain.

Example
{
  "provider": "Dynu",
  "password": "Your_Password",
  "domains": [
    {
      "domain_name": "your_domain.com",
      "sub_domains": [
        "your_subdomain"
      ]
    }
  ],
  "resolver": "8.8.8.8",
  "ip_urls": ["https://api.ip.sb/ip"],
  "ip_type": "IPv4",
  "interval": 300,
  "socks5_proxy": ""
}

IONOS

This is for IONOS Hosting Services, not IONOS Cloud. You'll need to sign up for API Access to Hosting Services, then create an API Key. You can find a full guide in the IONOS API Documentation. Note: The API-Key used by GoDNS must follow the form publicprefix.secret as described in the aforementioned documentation.

Example
provider: IONOS
login_token: publicprefix.secret
domains:
  - domain_name: example.com
    sub_domains:
      - somesubdomain
      - anothersubdomain
resolver: 1.1.1.1
ip_urls:
  - https://api.ipify.org
ip_type: IPv4
interval: 300
socks5_proxy: ""

Notifications

GoDNS can send a notification each time the IP changes.

Email

Emails are sent over SMTP. Update your configuration with the following snippet:

  "notify": {
    "mail": {
      "enabled": true,
      "smtp_server": "smtp.example.com",
      "smtp_username": "user",
      "smtp_password": "password",
      "smtp_port": 25,
      "send_from": "[email protected]"
      "send_to": "[email protected]"
    }
  }

Each time the IP changes, you will receive an email like that:

Telegram

To receive a Telegram message each time the IP changes, update your configuration with the following snippet:

  "notify": {
    "telegram": {
      "enabled": true,
      "bot_api_key": "11111:aaaa-bbbb",
      "chat_id": "-123456",
      "message_template": "Domain *{{ .Domain }}* updated to %0A{{ .CurrentIP }}",
      "use_proxy": false
    },
  }

The message_template property supports markdown. New lines needs to be escaped with %0A.

Slack

To receive a Slack message each time the IP changes, update your configuration with the following snippet:

  "notify": {
    "slack": {
      "enabled": true,
      "bot_api_token": "xoxb-xxx",
      "channel": "your_channel",
      "message_template": "Domain *{{ .Domain }}* updated to \n{{ .CurrentIP }}",
      "use_proxy": false
    },
  }

The message_template property supports markdown. New lines needs to be escaped with \n.

Discord

To receive a Discord message each time the IP changes, update your configuration with the following snippit:

  "notify": {
    "discord": {
          "enabled": true,
          "bot_api_token": "discord_bot_token",
          "channel": "your_channel",
          "message_template": "(Optional) Domain *{{ .Domain }}* updated to \n{{ .CurrentIP }}",
        }
  }

Pushover

To receive a Pushover message each time the IP changes, update your configuration with the following snippet:

  "notify": {
    "pushover": {
      "enabled": true,
      "token": "abcdefghijklmnopqrstuvwxyz1234",
      "user": "abcdefghijklmnopqrstuvwxyz1234",
      "message_template": "",
      "device": "",
      "title": "",
      "priority": 0,
      "html": 1
    }
  }

The message_template property supports html if the html parameter is 1. If it is left empty a default message will be used. If the device and title parameters are left empty, Pushover will choose defaults see. More details on the priority parameter can be found on the Pushover API description.

Webhook

Webhook is another feature that GoDNS provides to deliver notifications to the other applications while the IP is changed. GoDNS delivers a notification to the target URL via an HTTP GET or POST request.

The configuration section webhook is used for customizing the webhook request. In general, there are 2 fields used for the webhook request:

  • url: The target URL for sending webhook request.
  • request_body: The content for sending POST request, if this field is empty, a HTTP GET request will be sent instead of the HTTP POST request.

Available variables:

  • Domain: The current domain.
  • IP: The new IP address.
  • IPType: The type of the IP: IPV4 or IPV6.

Webhook with HTTP GET reqeust

"webhook": {
  "enabled": true,
  "url": "http://localhost:5000/api/v1/send?domain={{.Domain}}&ip={{.CurrentIP}}&ip_type={{.IPType}}",
  "request_body": ""
}

For this example, a webhook with query string parameters will be sent to the target URL:

http://localhost:5000/api/v1/send?domain=ddns.example.com&ip=192.168.1.1&ip_type=IPV4

Webhook with HTTP POST request

"webhook": {
  "enabled": true,
  "url": "http://localhost:5000/api/v1/send",
  "request_body": "{ \"domain\": \"{{.Domain}}\", \"ip\": \"{{.CurrentIP}}\", \"ip_type\": \"{{.IPType}}\" }"
}

For this example, a webhook will be triggered when the IP changes, the target URL http://localhost:5000/api/v1/send will receive an HTTP POST request with request body:

{ "domain": "ddns.example.com", "ip": "192.168.1.1", "ip_type": "IPV4" }

Miscellaneous topics

IPv6 support

Most of the providers support IPv6.

To enable the IPv6 support of GoDNS, there are two solutions to choose from:

  1. Use an online service to lookup the external IPv6

    For that:

    • Set the ip_type as IPv6, and make sure the ipv6_urls is configured
    • Create an AAAA record instead of an A record in your DNS provider
    Configuration example
    {
      "domains": [
        {
          "domain_name": "example.com",
          "sub_domains": ["ipv6"]
        }
      ],
      "resolver": "2001:4860:4860::8888",
      "ipv6_urls": ["https://api-ipv6.ip.sb/ip"],
      "ip_type": "IPv6"
    }
  2. Let GoDNS find the IPv6 of the network interface of the machine it is running on (more on that later).

    For this to happen, just leave ip_urls and ipv6_urls empty.

    Note that the network interface must be configured with an IPv6 for this to work.

Network interface IP address

For some reasons if you want to get the IP address associated to a network interface (instead of performing an online lookup), you can specify it in the configuration file this way:

  "ip_urls": [""],
  "ip_interface": "interface-name",

With interface-name replaced by the name of the network interface, e.g. eth0 on Linux or Local Area Connection on Windows.

Note: If ip_urls is also specified, it will be used to perform an online lookup first and the network interface IP will be used as a fallback in case of failure.

SOCKS5 proxy support

You can make all remote calls go through a SOCKS5 proxy by specifying it in the configuration file this way:

"socks5_proxy": "127.0.0.1:7070"
"use_proxy": true

Display debug info

To display debug info, set debug_info as true to enable this feature. By default, the debug info is disabled.

  "debug_info": true,

Multiple API URLs

GoDNS supports to fetch the public IP from multiple URLs via a simple round-robin algorithm. If the first URL fails, it will try the next one until it succeeds. Here is an example of the configuration:

  "ip_urls": [
  "https://api.ipify.org",
  "https://myip.biturl.top",
  "https://api-ipv4.ip.sb/ip"
  ],

Recommended APIs

Web Panel

Starting from version 3.1.0, GoDNS provides a web panel to manage the configuration and monitor the status of the domains. The web UI is disabled by default. To enable it, just enable the web_panel in the configuration file.

"web_panel": {
  "enabled": true,
  "addr": "0.0.0.0:9000",
  "username": "admin",
  "password": "123456"
}

After enabling the web panel, you can visit http://localhost:9000 to manage the configuration and monitor the status of the domains.

Running GoDNS

There are a few ways to run GoDNS.

Manually

Note: make sure to set the run_once parameter in your config file so the program will quit after the first run (the default is false).

Can be added to cron or attached to other events on your system.

{
  "...": "...",
  "run_once": true
}

Then run

./godns

As a manual daemon

nohup ./godns &

Note: when the program stops, it will not be restarted.

As a managed daemon (with upstart)

  1. Install upstart first (if not available already)

  2. Copy ./config/upstart/godns.conf to /etc/init (and tweak it to your needs)

  3. Start the service:

    sudo start godns

As a managed daemon (with systemd)

  1. Install systemd first (it not available already)

  2. Copy ./config/systemd/godns.service to /lib/systemd/system (and tweak it to your needs)

  3. Start the service:

    sudo systemctl enable godns
    sudo systemctl start godns

As a Docker container

Available docker registries:

Visit https://hub.docker.com/r/timothyye/godns to fetch the latest docker image. The -p 9000:9000 option is used to expose the web panel.

With /path/to/config.json as your local configuration file, run:

docker run \
-d --name godns --restart=always \
-v /path/to/config.json:/config.json \
-p 9000:9000 \
timothyye/godns:latest

To run it with a YAML config file:

docker run \
-d --name godns \
-e CONFIG=/config.yaml \
--restart=always \
-v /path/to/config.yaml:/config.yaml \
-p 9000:9000 \
timothyye/godns:latest

As a Windows service

  1. Download the latest version of NSSM

  2. In an administrative prompt, from the folder where NSSM was downloaded, e.g. C:\Downloads\nssm\ win64, run:

    nssm install YOURSERVICENAME
    
  3. Follow the interface to configure the service. In the "Application" tab just indicate where the godns.exe file is. Optionally you can also define a description on the "Details" tab and define a log file on the "I/O" tab. Finish by clicking on the "Install service" button.

  4. The service will now start along Windows.

Note: you can uninstall the service by running:

nssm remove YOURSERVICENAME

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Setup the frontend development environment

Requirements:

  • Node.js 18.19.0 or higher
  • Go 1.17 or higher

The frontend project is built with Next.js and daisyUI. To start the development environment, run:

cd web
npm ci
npm run dev

Build the frontend

To build the frontend, run:

cd web
npm run build

Run the frontend

To run the frontend, run:

cd web
npm run start

Special Thanks

Thanks JetBrains for sponsoring this project with free open source license.

I like GoLand, it is an amazing and productive tool.

godns's People

Contributors

6543 avatar adam-ah avatar apatura-iris avatar curzolapierre avatar dependabot[bot] avatar diizzyy avatar drewgingerich avatar ebastos avatar fisherms avatar gianttreelp avatar gruentee avatar gunsluo avatar hguandl avatar jemyzhang avatar jengell avatar jlsalvador avatar kenthua avatar kerma avatar kirbstomper avatar linyinfeng avatar phiwatec avatar razeencheng avatar rlei avatar sadpencil avatar shaworth avatar shizunge avatar sleavely avatar timothyye avatar tinysnake avatar x-liao avatar

Stargazers

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

Watchers

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

godns's Issues

Google Domains support

CheckSettings() in utils.go doesn't seem to do validation check if service is "Google".

As a result, any google config will return the error at the bottom of the if block, resulting in the "Settings is invalid! please provide supported DNS provider: DNSPod/HE/AliDNS/Cloudflare/GoogleDomain/DuckDNS" error.

Using latest 1.9 release.

My config.json:

{
  "provider": "Google",
  "email": "CENSORED",
  "password": "CENSORED",
  "domains": [{
      "domain_name": "CENSORED.net",
      "sub_domains": ["www","test"]
  }],
  "ip_url": "https://myip.biturl.top",
  "interval": 300,
  "socks5_proxy": ""
}

Notify on Amazon SES not working

Hi! First let me thank you for this awesome tool!

I'm trying to enable email notifications on IP changes on Cloudflare, the IP is being correctly updated, I'm running GoDNS as a systemd service on Debian Stretch with an unprivileged dedicated user named "godns". Here's my config.json:

{
  "provider": "Cloudflare",
  "email": "[email protected]",
  "password": "password",
  "domains": [
    {
      "domain_name": "domain.com",
      "sub_domains": ["subdomain"]
    }
  ],
  "ip_url": "https://icanhazip.com/",
  "ip_interface": "eth0",
  "socks5_proxy": "",
  "notify": {
    "enabled": true,
    "smtp_server": "email-smtp.us-east-1.amazonaws.com",
    "smtp_username": "username",
    "smtp_password": "password",
    "smtp_port": 587,
    "send_to": "[email protected]"
  }
}

I've tried port 25 too but it didn't work. Thanks in advance for any help!

不能正常获取IPv6

配置文件:

{
    "provider":"DNSPod",
    "login_token":"",
    "domains":[
        {
            "domain_name":"aaa.com",
            "sub_domains":[
                "ipv6.host"
            ]
        }
    ],
    "resolver": "2400:3200::1",
    "ip_url":"http://api-ipv6.ip.sb/ip",
    "ip_type":"IPv6",
    "interval":15
}

运行参数:

docker run -d --name godns --restart=always \
     -v `pwd`/dnspod.json:/usr/local/godns/config.json timothyye/godns:latest

运行日志:

[GoDNS] 2020/10/23 04:52:05 GoDNS started, entering main loop...
[GoDNS] 2020/10/23 04:52:05 Creating DNS handler with provider: DNSPod
[GoDNS] 2020/10/23 04:52:05 Checking IP for domain aaa.com
[GoDNS] 2020/10/23 04:52:06 Cannot get IP...
[GoDNS] 2020/10/23 04:52:06 get ip online failed. Fallback to get ip from interface if possible.
[GoDNS] 2020/10/23 04:52:06 currentIP is: 
[GoDNS] 2020/10/23 04:52:06 dial udp [2400:3200::1]:53: connect: cannot assign requested address
[GoDNS] 2020/10/23 04:52:06 Going to sleep, will start next checking in 15 seconds...

DNS 连通检测:

root@aarch64:~# ping6 2400:3200::1 -c 4
PING 2400:3200::1(2400:3200::1) 56 data bytes
64 bytes from 2400:3200::1: icmp_seq=1 ttl=119 time=32.0 ms
64 bytes from 2400:3200::1: icmp_seq=2 ttl=119 time=32.3 ms
64 bytes from 2400:3200::1: icmp_seq=3 ttl=119 time=32.2 ms
64 bytes from 2400:3200::1: icmp_seq=4 ttl=119 time=32.4 ms

--- 2400:3200::1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 32.026/32.279/32.476/0.244 ms

CURL IP URL 测试:

root@aarch64:~# curl https://api-ipv6.ip.sb/ip -6
240e:358:8b20:xxxxxxxx
root@aarch64:~# curl http://api-ipv6.ip.sb/ip -6
240e:358:8b20:xxxxxxxx
root@aarch64:~# 

网卡信息:

root@aarch64:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:1c:42:xxxxxx brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.100/24 brd 192.168.123.255 scope global dynamic enp0s5
       valid_lft 85713sec preferred_lft 85713sec
    inet6 240e:358:8b20:xxxxxxxx/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 591sec preferred_lft 591sec
    inet6 fe80::xxxxxxxx/64 scope link 
       valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:2a:xxxxxx brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:2aff:fe5b:46f0/64 scope link 
       valid_lft forever preferred_lft forever
5: vethc76d3e7@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether fa:e3:31:xxxxxx brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::f8e3:31ff:feca:8fc1/64 scope link 
       valid_lft forever preferred_lft forever
root@aarch64:~# 

自己 golang 编译也测试过,也无法正常获取 网卡 enp0s5 可以获取局域网 IPv4 与 公网 IPv6。

ip比较错误

dnspod_handler.go中用strings.Contains会出问题的
// Continue to check the IP of sub-domain
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
例:currentIp=192.168.100.234,ip=192.168.100.2

no log? I start the docker and nothing happen.

I check the log file :/var/lib/docker/containers/a9572ee726a5ca500857f03eae9a9078df707f164457006d0e9accca5c6da776/a9572ee726a5ca500857f03eae9a9078df707f164457006d0e9accca5c6da776-json.log

and there is nothing.

DNSPod无法更新解析

你好,进程启动后DNSPOD无法更新A记录
请帮忙看看是哪里问题呢?非常感谢!
【GoDNS】2018/07/31 15:00:22 debug: 0 www
【GoDNS】2018/07/31 15:00:22 get_subdomain:status code: 10001
【GoDNS】2018/07/31 15:00:22 domain: www.pipiv.com subDomainID: ip:
【GoDNS】2018/07/31 15:00:22 debug: 0 test
【GoDNS】2018/07/31 15:00:22 get_subdomain:status code: 10001
【GoDNS】2018/07/31 15:00:22 domain: test.pipiv.com subDomainID: ip:
【GoDNS】2018/07/31 15:00:22 Going to sleep, will start next checking in 5 minutes...
【GoDNS】2018/07/31 15:05:22 Checking IP for domain pipiv.com
【GoDNS】2018/07/31 15:05:22 get_domain:status code: 10001
【GoDNS】2018/07/31 15:05:23 currentIP is: 47.52.71.33

【GoDNS】2018/07/31 15:05:23 debug: 0 www
【GoDNS】2018/07/31 15:05:23 get_subdomain:status code: 10001
【GoDNS】2018/07/31 15:05:23 domain: www.pipiv.com subDomainID: ip:
【GoDNS】2018/07/31 15:05:23 debug: 0 test
【GoDNS】2018/07/31 15:05:23 get_subdomain:status code: 10001
【GoDNS】2018/07/31 15:05:23 domain: test.pipiv.com subDomainID: ip:
【GoDNS】2018/07/31 15:05:23 Going to sleep, will start next checking in 5 minutes...
【GoDNS】2018/07/31 15:10:23 Checking IP for domain pipiv.com
【GoDNS】2018/07/31 15:10:23 get_domain:status code: 10001
【GoDNS】2018/07/31 15:10:25 currentIP is: 47.52.71.33

exec user process caused "exec format error"

I'm getting this error when trying to use on a raspberry 4 docker:

standard_init_linux.go:211: exec user process caused "exec format error"

I'm new on docker, any idea about this issue? I've tried the docker command from docs.

更新DDNS失败了呢,能帮我看下是什么原因吗?

【GoDNS】2018/05/09 03:01:59 GoDNS started, entering main loop...,
【GoDNS】2018/05/09 03:02:00 Going to sleep, will start next checking in 5 minutes...
,
【GoDNS】2018/05/09 03:01:59 Creating DNS handler with provider: DNSPod,
【GoDNS】2018/05/09 03:01:59 get_domain:status code: 10001,
【GoDNS】2018/05/09 03:01:59 currentIP is: 27.115.62.210,
,
【GoDNS】2018/05/09 03:01:59 savedIP is: ,
【GoDNS】2018/05/09 03:01:59 debug: 0 www,
【GoDNS】2018/05/09 03:02:00 get_subdomain:status code: 10001,
【GoDNS】2018/05/09 03:02:00 domain: www.oudev.com subDomainID:  ip: ,
【GoDNS】2018/05/09 03:02:00 debug: 0 test,
【GoDNS】2018/05/09 03:02:00 domain: test.oudev.com subDomainID:  ip: ,
【GoDNS】2018/05/09 03:02:00 currentIP is: 27.115.62.210,
【GoDNS】2018/05/09 03:02:00 savedIP is: 27.115.62.210,
【GoDNS】2018/05/09 03:02:00 Current IP is not changed, no need to update...

上面的是日志。

didnt updated domain - Cloudflare

GoDNS works correctly on subdomains like "www" or "test". But it seems to be that only subdomains got updated. Domains like "example.com" got ignored. (Only tested by using Cloudflare)

Need retry for failed updates

The current behavior seems to be that if a record update ever fails, that record will stay failed, and will never be retried until the IP changes.

HE.net updates seem to fail fairly often.

Example logs:

godns_1                   | 【GoDNS】2018/06/12 05:11:02 GoDNS started, entering main loop...
godns_1                   | 【GoDNS】2018/06/12 05:11:02 Creating DNS handler with provider: HE
godns_1                   | 【GoDNS】2018/06/12 05:11:03 currentIP is: x.x.x.x
godns_1                   | 
godns_1                   | 【GoDNS】2018/06/12 05:11:03 a.redacted.com Start to update record IP...
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Update IP success: nochg x.x.x.x
godns_1                   | 【GoDNS】2018/06/12 05:11:03 b.redacted.com Start to update record IP...
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Request error...
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Err: Post https://dyn.dns.he.net/nic/update: EOF
godns_1                   | 【GoDNS】2018/06/12 05:11:03 c.redacted.com Start to update record IP...
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Request error...
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Err: Post https://dyn.dns.he.net/nic/update: EOF
godns_1                   | 【GoDNS】2018/06/12 05:11:03 Going to sleep, will start next checking in 5 minutes...
godns_1                   | 【GoDNS】2018/06/12 05:16:05 currentIP is: x.x.x.x
godns_1                   | 
godns_1                   | 【GoDNS】2018/06/12 05:16:05 Current IP is not changed, no need to update...
godns_1                   | 【GoDNS】2018/06/12 05:16:05 Going to sleep, will start next checking in 5 minutes...

ability to update domain and subdomains

same issue as in #33
where you replied on adding the ability to update domain and subdomain, altogether

Good suggestion! I'll consider to add it, thanks!

Originally posted by @TimothyYe in #33 (comment)

later issue #33 got offtrack and closed

is there any chance to have this ability on future releases?

here's my config:

      "domain_name": "example.com"
    },{
      "domain_name": "example.com",
      "sub_domains": ["*"]
    }
  ],

Invalid request headers - Cloudflare

Hi there,

I'm running the app in docker.

docker version                                                         ─╯
Client:
 Version:           18.09.9
 API version:       1.39
 Go version:        go1.13.4
 Git commit:        1752eb3
 Built:             Sat Nov 16 01:05:26 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.9
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.13.4
  Git commit:       9552f2b
  Built:            Sat Nov 16 01:07:48 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Using the following docker-compose file:

---
version: "2"
services:
  godns:
    image: timothyye/godns
    container_name: godns
    volumes:
      - /home/dustin/docker/godns/config.json:/usr/local/godns/config.json
    restart: unless-stopped

My godns config file looks like:

cat config.json                                                        ─╯
{
    "provider": "Cloudflare",
    "email": "[email protected]",
    "password": "xxxxxxxxxxx",
    "domains": [
        {
            "domain_name": "xxxxxxxx.com",
            "sub_domains": [
                "xxxxx"
            ]
        }
    ],
    "ip_url": "https://myip.biturl.top",
    "interval": 300,
    "socks5_proxy": ""
}

After starting with docker-compose -d up I then have a look at the logs with docker logs --tail 50 --follow --timestamps godns. I then see the following error:

2020-01-03T22:45:04.007390136Z [GoDNS] 2020/01/03 22:45:04 Response failed: {"success":false,"errors":[{"code":6003,"message":"Invalid request headers","error_chain":[{"code":6103,"message":"Invalid format for X-Auth-Key header"}]}],"messages":[],"result":null}

Any suggestions?

EDIT
PS Thank you!

New Cloudflare API Token

It would be great if Cloudflare's new authentication was implemented using tokens, which have granular access control.

API Tokens use the standard Authorization: Bearer header for authentication instead of x-auth-email and x-auth-key that API Keys use. Requests can be authenticated like the following:

curl -X GET "https://api.cloudflare.com/client/v4/zones/cd7d0123e3012345da9420df9514dad0" \ 
-H "Content-Type:application/json" \ 
-H "Authorization: Bearer 1234567893feefc5f0q5000bfo0c38d90bbeb"```

multi-wan support

I have four WANs named from netwan1,netwan2...netwan4 which means I have 4 public ipv4 address and I want to dynamic dns all of them.

However, godns seems only support single WAN interface,

can godns support multi-wan?

Support getting `IP` from interface wan or other

My situation is that:

I get public IP when I dial the pppoe, therefore I do not need to query IP from a website/api

Besides, I dial more than one pppoe and get more than one IP so I have multi-wans and my outbouding IP changes in corresponding to network usage.

Therefore, I cannot rely on querying from a website.

Suggestion

Add an option to get IP from command like ipconfig or ip address show
Also, users can specify which interface to query, eg wan

I am sorry for not reading READMD carefully

Webhook

Add webhook feature, let GoDNS be able to send HTTP POST/GET requests while IP is changed and updated.

Google DNS not working - potentially need to set user agent string

godns 1.9.1 doesn't seem to successfully update my ddns with Google. The messaging looks successful:

C:\Users\jeff\Desktop\GoDNS>godns.exe
[GoDNS] 2019/08/30 18:46:20 GoDNS started, entering main loop...
[GoDNS] 2019/08/30 18:46:20 Creating DNS handler with provider: Google
[GoDNS] 2019/08/30 18:46:21 currentIP is: [censored]
[GoDNS] 2019/08/30 18:46:21 Going to sleep, will start next checking in 300 seconds...

however, checking Google Domains, the last update for my DNS was stated to be months ago.

To check, I made the request directly via a browser to the end point using the same config/username/password/domain, and this successfully updated my ddns IP.
https://CENSORED:[email protected]/nic/update?hostname=CENSORED.net&myip=CENSORED

I noticed that UpdateIP() in the Google handler does not set a user agent when sending the request to the Google API endpoint. Per Google's API documentation, you should set a user agent when updating DNS: "Note: You must set a user agent in your request as well. Web browsers will generally add this for you when testing via the above url."

Note the user agent might be required for other services as well, as it is one of the few things public API endpoints can use to ban "bad" bots who improperly use APIs without actually banning specific IPs directly - not saying this is the case here, but just noting in general.

Edit: is there a way I can set user agent via the configuration?

Set IPv4 AND IPv6

Hello,

is there a possibility to let GoDNS manage my IPv4 AND my IPv6 DNS records?

Thanks!

出现一个问题,求解答

日志显示ip错误
QQ截图20200826174945
但实际上这个IP没问题,而且有时候就更新成功了,有时候就会这样显示
dns服务商为dnspod

Update doc of GetIPFromInterface

https://github.com/TimothyYe/godns#get-an-ip-address-from-the-interface

Get an IP address from the interface

For some reasons if you want to get an IP directly from the interface, say eth0 for Linux or Local Area Connection for Windows, update config file like this:

"ip_url": "",
"ip_interface": "eth0",

If you set both ip_url and ip_interface, it first tries to get an IP address online, and if not succeed, gets an IP address from the interface as a fallback.

Note that IPv6 address will be ignored currently.

The above behavior is not correct now as GoDNS supports IPv6.

https://github.com/TimothyYe/godns#ipv6-support

To enable the IPv6 mode of GoDNS, you only need two steps:

Set the ip_type as IPv6, and make sure the ipv6_url is configured.
Add one AAAA record to your provider.

The above is not correct now. Even if ipv6_url is not configured, as long as ip_interface is set, GoDNS can still obtain an IPv6 address.

Support for bind and other dns direct records zones updates or using a single url\request.

I have been working with bind and have a dynamic DNS system up and running.
The most successful system I have built is based on http\https api and bind zone control with keys.
Technically I would expect from a "general" service to use a username+password+domain+other specific options set as a simple GET or POST methods.
And on the other hand there is the "Zone update" option which is a part of the DNS standard.
What do you think about each of these general options to be added later on?

第二次执行提示这个属于正常吗

UpdateDomainRecord error.Status 400, Error:{"RequestId":"8DDD65EF-500D-49FA-8418-CC6016AEC07A","HostId":"alidns.aliyuncs.com","Code":"DomainRecordDuplicate","Message":"The DNS record already exists."}
当前应该是尝试添加了一次吧,而没有去判断这个解释是否存在,存在去修改,不存在去添加新

树莓派无法安装

作者您好,您提供的都是X64的,我看到您写了支持树莓派,但是我的树莓派是32位的,无法使用。使用go语言的话不知道为什么也不能编译,正常的X64的CentOS 7 的系统可以编译

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.