Setup ddclient Dynamic DNS FreeBSD With He Net DDNS Server

Table Of Content:

System Specifications
What is Dynamic DNS
Adding a Domain on HeNet
DDClient Installation
DDClient Configuration
Test DDClient



1. System Specifications

OS: FreeBSD 13.2 Stable
Interface: nfe0
IP Interface nfe0: 192.168.5.2
Hostname: ns6
Domain: datainchi.com
ddclient version: ddclient-3.9.1
Internet Service Provider: MyIndiHome (PT. Telkom Indonesia)


2. What is Dynamic DNS

Often when we browse the Internet, we need a static IP address. The IP can be obtained by contacting your Internet provider directly, or by using a special service called Dynamic DNS (also called DynDNS, DDNS, or DinDNS). Let's discuss the second option in more detail. Dynamic DNS is a service that assigns specific IP addresses to network equipment, so that users can connect to their equipment from anywhere with a static IP.

Many modern routers support the DDNS protocol. Not everyone knows why it is needed and how to use it. In short, DDNS is Dynamic DNS, a way to update domain name information on a server. When your router connects to the Internet, it is automatically assigned an IP address. If this is an external address called a “white” address, then you can use it to access the router not only from your home network, but also from any device connected to the Internet from outside your home.

However, providers usually issue dynamic IP addresses, which are subject to change. After changing it, access to the router will be lost. Thanks to dynamic DNS services, you can assign a domain name to your router and not lose access even if the provider changes the IP address.
Other computers on the network can connect to your gadget and not realize that the address has changed. Now that we know about DDNS and understand what it is, it will be easier for us to understand how to use it.


3. Adding a Domain on HeNet

HeNet is a service that provides a variety of security and optimization services that help both small sites and large projects. Using HeNet, you can protect your website from DDoS attacks, set up website optimization, caching, secure connection, analyze traffic, and more. We will discuss many functions in this article.

To create a 3rd level domain from my second level domain and bind this 3rd level domain to HE.net by assigning this domain name to the name server of HE.net. (This needs to be done at the name server of the second level domain).

The first step is to LogIn to the H.Net site. Then add a domain by clicking the "Add a new domain" menu.





After that, we click ns1.datainchi.com, ns2.datainchi.com, ns3.datainchi.com, ns4.datainchi.com and ns1.datainchi.com then edit. Activate the "Enable entry for dynamic dns" option.



The IPv4 Address option will be filled in automatically by the He.Net server according to the Internet Service Provider (ISP) IP. In this article the dynamic IP of the Internet Service Provider (ISP) is 36.90.9.139.


4. DDClient Installation

Before we install ddclient, we must first install the dependencies used by ddclient. Below are the dependencies that must be installed.
root@ns6:~ # pkg install curl gmake autoconf automake perl5 p5-Data-Validate-IP
Then we install ddclient, use the FreeBSD ports system so that all dependencies can be installed perfectly.
root@ns6:~ # cd /usr/ports/dns/ddclient
root@ns6:/usr/ports/dns/ddclient # make install clean
Below is the script from the developer after the ddclient installation process is complete

===>  Installing for ddclient-3.9.1
===>  Checking if ddclient is already installed
===>   Registering installation for ddclient-3.9.1
Installing ddclient-3.9.1...
To configure ddclient, edit the following file:

        /usr/local/etc/ddclient.conf

If you would like to run ddclient as a daemon add the
following line to /etc/rc.conf

        ddclient_enable="YES"

If you would like to force ddclient to update your account
daily regardless of IP changes add the following line to
your /etc/periodic.conf

        daily_ddclient_force_enable="YES"

===>  Cleaning for ddclient-3.9.1



5. DDClient Configuration

So that ddclient can run automatically on the FreeBSD server, create the rc.d script in the /etc/rc.conf file and enter the script below in that file.
root@ns6:/usr/ports/dns/ddclient # ee /etc/rc.conf
ddclient_enable="YES"
If you would like to force ddclient to update your account daily regardless of IP changes add the following line to your /etc/periodic.conf.
root@ns6:~ # touch  /etc/periodic.conf
root@ns6:~ # chmod +x /etc/periodic.conf
root@ns6:~ # ee /etc/periodic.conf
daily_ddclient_force_enable="YES"
ddclient is a Perl client used to update dynamic DNS entries for accounts on many dynamic DNS services. It uses curl for internet access. DDClient requires a configuration file with appropriate settings to function. File configurasi DDClient bernama ddclient.conf.

After installing ddclient, you have to create/edit /usr/local/etc/ddclient.conf. Below is a sample configuration which updates IP address for third level hostname HeNet.
root@ns6:~ # ee /usr/local/etc/ddclient.conf

daemon=300				# check every 300 seconds
syslog=yes				# log update msgs to syslog
mail=root				# mail all msgs to root
mail-failure=root			# mail failed update msgs to root
pid=/var/run/ddclient.pid		# record PID in file.
ssl=yes					# use ssl-support.  Works with

use=ip,                     ip=192.168.5.2
use=if,                     if=nfe0
#use=web					# via web
use=web, web=whatismyip.org
protocol=dyndns2				# default protocol
server=dyn.dns.he.net  # default
login=kanakarobih
password=E1WAP1J6rTu0Rdy4
www.datainchi.com,datainchi.com
In the LogIn option, fill in the username from the He.Net site.



In the Password option, fill in the password from the He.Net site.




After that restart DDClient.
root@ns6:~ # service ddclient restart
Stopping ddclient.
Waiting for PIDS: 862.
Starting ddclient.


6. Test DDClient

If you use the Unbound DNS Server, activate the following script in the /usr/local/etc/unbound/unbound.conf file.

outgoing-interface: 0.0.0.0

Use the command below to check whether DDClient is connected to the He.Net Server.
root@ns6:~ # dig www.datainchi.com

; <<>> DiG 9.18.20 <<>> www.datainchi.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 251
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.datainchi.com.             IN      A

;; ANSWER SECTION:
www.datainchi.com.      86400   IN      CNAME   datainchi.com.
datainchi.com.          86400   IN      A       36.90.9.139
datainchi.com.          86400   IN      A       192.168.5.2

;; Query time: 0 msec
;; SERVER: 192.168.5.2#53(192.168.5.2) (UDP)
;; WHEN: Sun Nov 26 09:20:31 WIB 2023
;; MSG SIZE  rcvd: 92

root@ns6:~ # nslookup www.datainchi.com
Server:         192.168.5.2
Address:        192.168.5.2#53

Non-authoritative answer:
www.datainchi.com       canonical name = datainchi.com.
Name:   datainchi.com
Address: 36.90.9.139
Name:   datainchi.com
Address: 192.168.5.2
root@ns6:~ # dig datainchi.com

; <<>> DiG 9.18.20 <<>> datainchi.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62339
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;datainchi.com.                 IN      A

;; ANSWER SECTION:
datainchi.com.          85650   IN      A       36.90.9.139
datainchi.com.          85650   IN      A       192.168.5.2

;; Query time: 0 msec
;; SERVER: 192.168.5.2#53(192.168.5.2) (UDP)
;; WHEN: Sun Nov 26 09:33:01 WIB 2023
;; MSG SIZE  rcvd: 74

IP 36.90.9.139 is a dynamic Public IP originating from the Internet Service Provider (ISP) and IP 192.168.5.2 is the Unbound DNS Server Private IP.

If the inspection results show results as above, it means that DDClient is connected to the He.Net dynamic server.


7. Update IP Public ISP

After DDClient has successfully connected to the server He.Net and get a Public IP from the ISP, the next step is to create an update script to get a Public IP automatically. Public IP update requests can be sent via http or https.

The most basic example of a Public IP update.

curl "https://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com&myip=192.168.0.1"

From the example script above, change the password according to your DDClient password, namely E1WAP1J6rTu0Rdy4, replace the hostname with the hostname that we created on the He.Net site, for example ns1.datainchi.com and replace the IP address with your FreeBSD private server IP, namely 192.168.5.2.

Look at the writing example below and see the results. If the word "good" appears, the DDClient public IP has been successfully updated.
root@ns6:~ # curl "https://ns1.datainchi.com:E1WAP1J6rTu0Rdy4@dyn.dns.he.net/nic/update?hostname=ns1.datainchi.com&myip=192.168.5.2"
good 192.168.5.2root@ns6:~ #
After reading and practicing the article in depth, it is clear that the article provides useful knowledge regarding How to Set up Dynamic DNS on a FreeBSD server. From start to finish, the author presents an in-depth understanding of the topic. Thank you for reading this article. If you require further information, please contact via email.
Iwan Setiawan

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

Post a Comment

Previous Post Next Post