██████╗ ██████╗ ██████╗ ███╗ ██╗███████╗
██╔════╝ ██╔═══██╗██╔══██╗████╗ ██║██╔════╝
██║ ███╗██║ ██║██║ ██║██╔██╗ ██║███████╗
██║ ██║██║ ██║██║ ██║██║╚██╗██║╚════██║
╚██████╔╝╚██████╔╝██████╔╝██║ ╚████║███████║
╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
GoDNS is a dynamic DNS (DDNS) client tool, it is based on my early open source project: DynDNS.
Now I rewrite DynDNS by Golang and call it GoDNS.
- Cloudflare (https://cloudflare.com)
- Google Domains (https://domains.google)
- DNSPod (https://www.dnspod.cn/)
- HE.net (Hurricane Electric) (https://dns.he.net/)
- AliDNS (https://help.aliyun.com/product/29697.html)
- DuckDNS (https://www.duckdns.org)
- Linux
- MacOS
- ARM Linux (Raspberry Pi, etc...)
- Windows
- MIPS32 platform
To compile binaries for MIPS (mips or mipsle):
GOOS=linux GOARCH=mips/mipsle GOMIPS=softfloat go build -a
And the binary can run well on routers.
-
Register and own a domain.
-
Domain's nameserver points to DNSPod or HE.net or Cloudflare or Google Domains or AliDNS.
-
Or just register an account from DuckDNS.
- Get source code from Github:
git clone https://github.com/timothyye/godns.git
- Go into the godns directory, get related library and then build it:
cd cmd/godns
go get -v
go build
Download compiled binaries from releases
$ ./godns -h
Usage of ./godns:
-c string
Specify a config file (default "./config.json")
-h Show help
- Get config_sample.json from Github.
- Rename it to config.json.
- Configure your provider, domain/subdomain info, username and password, etc.
- Configure the SMTP options if you want, a mail notification will sent to your mailbox once the IP is changed.
- Save it in the same directory of GoDNS, or use -c=your_conf_path command.
- provider: The providers that GoDNS supports, available values are:
Cloudflare
,Google
,DNSPod
,AliDNS
,HE
,DuckDNS
. - email: Email or account name of your DNS provider.
- password: Password of your account.
- login_token: Login token of your account.
- domains: Domains list, with your sub domains.
- ip_url: A site helps you to get your public IP address.
- interval: The interval
seconds
that GoDNS check your public IP. - socks5_proxy: Socks5 proxy server.
For Cloudflare, you need to provide email & Global API Key as password, and config all the domains & subdomains.
{
"provider": "Cloudflare",
"email": "you@example.com",
"password": "Global API Key",
"domains": [{
"domain_name": "example.com",
"sub_domains": ["www","test"]
},{
"domain_name": "example2.com",
"sub_domains": ["www","test"]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
For DNSPod, you need to provide your API Token(you can create it here), and config all the domains & subdomains.
{
"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"]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
For Google Domains, you need to provide email & password, and config all the domains & subdomains.
{
"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"]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
For AliDNS, you need to provide AccessKeyID
& AccessKeySecret
as email
& password
, and config all the domains & subdomains.
{
"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"]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
For DuckDNS, only need to provide the token
, config 1 default domain & subdomains.
{
"provider": "DuckDNS",
"password": "",
"login_token": "3aaaaaaaa-f411-4198-a5dc-8381cac61b87",
"domains": [
{
"domain_name": "www.duckdns.org",
"sub_domains": [
"myname"
]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
For HE, email is not needed, just fill DDNS key to password, and config all the domains & subdomains.
{
"provider": "HE",
"password": "YourPassword",
"login_token": "",
"domains": [{
"domain_name": "example.com",
"sub_domains": ["www","test"]
},{
"domain_name": "example2.com",
"sub_domains": ["www","test"]
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"socks5_proxy": ""
}
Add a new "A record", make sure that "Enable entry for dynamic dns" is checked:
Fill your own DDNS key or generate a random DDNS key for this new created "A record":
Remember the DDNS key and fill it as password to the config.json.
NOTICE: If you have multiple domains or subdomains, make sure their DDNS key are the same.
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.
Update config file and provide your SMTP options, a notification mail will be sent to your mailbox once the IP is changed and updated.
"notify": {
"enabled": true,
"smtp_server": "smtp.example.com",
"smtp_username": "user",
"smtp_password": "password",
"smtp_port": 25,
"send_to": "my_mail@example.com"
}
Notification mail example:
You can also use SOCKS5 proxy, just fill SOCKS5 address to the socks5_proxy
item:
"socks5_proxy": "127.0.0.1:7070"
Now all the queries will go through the specified SOCKS5 proxy.
nohup ./godns &
- Install
upstart
first - Copy
./upstart/godns.conf
to/etc/init
- Start it as a system service:
sudo start godns
- Modify
./systemd/godns.service
and config it. - Copy
./systemd/godns.service
to/lib/systemd/system
- Start it as a systemd service:
sudo systemctl enable godns
sudo systemctl start godns
Now godns supports to run in docker.
- Get config_sample.json from Github.
- Rename it to config.json.
- Run GoDNS with docker:
docker run -d --name godns --restart=always \
-v /path/to/config.json:/usr/local/godns/config.json timothyye/godns:latest
After creating your config.json file:
- Get the latest NSSM for create a windows service.
- Open the command prompt (as administrator) in the folder where you downloaded NSSM (e.g. C:\Downloads\nssm\ win64) and run:
nssm install YOURSERVICENAME
You will have an interface to configure your service, it is very simple in the "Application" tab just indicate where your 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 using the "Install service" button.
- Done. Now whenever windows start your service will be loaded.
- To uninstall:
nssm remove YOURSERVICENAME