Dynamic DNS With GoDNS Alternative ddclient On FreeBSD

GoDNS is a dynamic DNS (DDNS) client tool. GoDNS is written in Go Lang and is an open source DynDNS project. GoDNS supports various domain providers and allows creating notifications when changes are made via email (SMTP) or using services such as Discord, Pushover, Slack, and Telegram.

GoDNS supports many platforms such as Linux, FreeBSD, MacOS, Windows and others. The existence of this application has proven to be very tough, stable and light. In fact, GoDNS can replace ddclient which has long mastered the Dynamic DNS (DDNS) application.

Similar to the ddclient application, GoDNS also supports multiple DNS providers. The image below is the DNS providers supported by GoDNS.

In this tutorial, we will learn how to install and configure Dynamic DNS (DDNS) on a FreeBSD server via GoDNS and HE.net.

To use GoDNS on FreeBSD, it is assumed:
  1. The GO application has been installed on FreeBSD.
  2. You registered (now own) a domain.
  3. The domain has been delegated to a supported DNS provider, such as HE.net or cloudflare.
  4. If you don't have a domain yet, alternatively you can log in to DuckDNS (with a social account) and get a subdomain on the duckdns.org domain for free.

1. System specifications

OS: FreeBSD 13.2
domain: datainchi.com
Hostname: ns7
IP Address:
Land Card: nfe0
Provider DDNS: HE.net

2. Installing GoDNS on FreeBSD

Before we start the installation process, you should read the article on how to install and configure GO on FreeBSD.

Because GoDNS is written in Go Language, make sure your FreeBSD has GO installed. On FreeBSD the GoDNS repository is available in system ports, but I prefer to install it with the binary package. You can package the entire library on the official GitHub site and run it in Go language. This method ensures that it is the latest version.
root@ns7:~ # cd /usr/local/etc
root@ns7:/usr/local/etc # git clone https://github.com/TimothyYe/godns.git
Cloning into 'godns'...
remote: Enumerating objects: 3196, done.
remote: Counting objects: 100% (277/277), done.
remote: Compressing objects: 100% (90/90), done.
remote: Total 3196 (delta 200), reused 236 (delta 181), pack-reused 2919
Receiving objects: 100% (3196/3196), 1.72 MiB | 433.00 KiB/s, done.
Resolving deltas: 100% (1660/1660), done.
After cloning godns from Github repository, continue with "build installation".
root@ns7:/usr/local/etc # cd godns/cmd/godns
root@ns7:/usr/local/etc/godns/cmd/godns # go mod download
root@ns7:/usr/local/etc/godns/cmd/godns # go build
root@ns7:/usr/local/etc/godns/cmd/godns # go install
root@ns7:~ # mkdir -p /var/run/godns
root@ns7:~ # chmod +x /var/run/godns

The go mod download command will install GoDNS dependency files, while the go install command will produce bin files "godns". Perform the move command so that the bin files "godns" can run on the FreeBSD system.
root@ns7:/usr/local/etc/godns/cmd/godns # mv /root/go/bin/godns /usr/local/bin

3. Configuration GoDNS

Before configuring, let's look at the guide for using GoDNS.
root@ns7:/usr/local/etc/godns/cmd/godns # godns -h

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

GoDNS 0.1

Usage of godns:
  -c string
        Specify a config file (default "./config.json")
  -h    Show help
Create a config.json file and place it in the folder "/usr/local/etc/godns".
root@ns7:~ # touch /usr/local/etc/godns/godns-config.json
root@ns7:~ # chmod -R 777 /usr/local/etc/godns/godns-config.json
Below is an example script from the file "/usr/local/etc/godns/godns-config.json".

  "provider": "HE",
  "password": "maCpVY9JnjEXJCi1",
  "email": "kanakarobih",
  "domains": [
      "domain_name": "datainchi.com",
      "sub_domains": ["www"]
  "ip_urls": [
  "ipv6_urls": ["https://ipify.org"],
  "ip_type": "IPv4",
  "interval": 300,
  "resolver": "",
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36",
  "ip_interface": "nfe0",
  "socks5_proxy": "",
  "use_proxy": false,
  "debug_info": true,
  "proxied": false,
  "notify": {
    "telegram": {
      "enabled": false,
      "bot_api_key": "",
      "chat_id": "",
      "message_template": ""
    "mail": {
      "enabled": false,
      "smtp_server": "",
      "smtp_username": "",
      "smtp_password": "",
      "smtp_port": 25,
      "send_from": "",
      "send_to": ""
  "webhook": {
    "enabled": false,
    "url": "http://localhost:5000/api/v1/send",
    "request_body": "{ \"domain\": \"{{.Domain}}\", \"ip\": \"{{.CurrentIP}}\", \"ip_type\": \"{{.IPType}}\" }"

In the script above the "password" and "email" come from the DDNS provider HE.net. Email comes from Account Name HE.net

root@ns7:~ # godns -c=/usr/local/etc/godns/godns-config.json
INFO[0000] Creating DNS handler with provider: HE
INFO[0000] GoDNS started, starting the DNS manager...
DEBU[0001] get ip success by: https://dns.he.net, online IP:
DEBU[0001] get ip success by: https://dns.he.net, online IP:
INFO[0002] Update IP success: badauth
DEBU[0002] Cached IP address:
DEBU[0002] DNS update loop finished, will run again in 300 seconds
You have successfully run GoDNS on the FreeBSD server. But unfortunately the DoDNS daemon does not run automatically. OK, now we will make the GoDNS daemon run automatically using the rc.d script.

Create a godns rc.d file in the /usr/local/etc/rc.d folder.
root@ns7:~ # touch /usr/local/etc/rc.d/godns
root@ns7:~ # chmod +x /usr/local/etc/rc.d/godns
In the file "/usr/local/etc/rc.d/godns" write the script below.


# PROVIDE: godns
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf to enable godns:
# godns_enable (bool):		Set to "NO" by default.
#				Set it to "YES" to enable godns.
# godns_flags (str):		Custom additional arguments to be passed
#				to godns (default empty).
# godns_conf_dir (str):		Directory where ${name} configuration
#				data is stored.

. /etc/rc.subr


load_rc_config ${name}

: ${godns_enable:="NO"}
: ${godns_user:="nobody"}
: ${godns_group:="nogroup"}
: ${godns_conf_dir="/usr/local/etc"}




command_args="-f -t ${name} -o ${logfile} -p ${pidfile} ${procname} -c ${required_files} ${godns_args}"

	local rundir=${pidfile%/*}
	if [ ! -d $rundir ] ; then
		install -d -m 0755 -o ${godns_user} -g ${godns_group} $rundir
	local logdir=${logfile%/*}
	install -d -m 0750 -o ${godns_user} -g ${godns_group} $logdir

	rm -f "$rundir"

run_rc_command "$1"

Then in the /etc/rc.conf file, add the following script.
root@ns7:~ # ee /etc/rc.conf
The final step is to run GoDNS, whether it can run automatically on the FreeBSD server.
root@ns7:~ # service godns restart
With the rc.d script, your GoDNS can run automatically. You no longer need to run it manually.

All the features available in GoDNS are no less than a similar application, namely ddclient. You have to try it so that you can feel the benefits of GoDNS. We have tried it, and the results are very satisfying.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post