by Devin Yang
(This article was automatically translated.)

Published - 4 years ago ( Updated - 4 years ago )

My family uses HiNet optical generation dial-up access to the Internet, and the optical generation one is fixed and seven floating IPs.

A while ago, I changed to a Wifi, D-Link DIR-882, to be honest, this one is expensive and rotten@@,
I’m not sure if it’s because I bought the King of Machines, and the machine often crashes, and then, the DDNS function provided by him is gone,
It's set up, but it doesn't seem to be updating, so it doesn't work very well.



The point is, the above FAQ description does not seem to be free, will it be charged after six months?
Registering your D-Link product will allow you to continue using dynamic DNS with your D-Link registered product Without interruption for the period specified for the product, which is generally up to six months.
 
So I tried Google several free DDNS service companies, big first, said it is free but actually requires money,
For example, spend a fee, activate their update tool point,
To put it simply, it will cause some inconvenience to you. If you want full functions, you still need to spend money. I don’t want to spend money on DDNS.

(Note: There are still some, which are said to be really free, but I haven't tried any more, you can Google yourself.)

So, let me think, I have a Synology NAS at home, doesn't it also provide DDNS function? I want to try it.

Let me talk about my environment first. My home NAS is dialed to a fixed IP of Hi-Net PPPOE.
And the main implementation of my Nas is the website you see now.

Individual users, who have no budget to play with AWS or GCP, use this Nas to build their own website,
Personal website for writing articles, and then execute the docker environment of D-Laravel:),
You can run a large number of services with docker, but you can only run a few with VM.

How to run D-Laravel with Synaloge NAS, you can refer to my chowner article.
https://www.ccc.tc/article/d-laravel-chowner

In addition, I installed a VM with Nas to build an online conference system.


This VM comes in through the DMZ set up through the Wifi Router on the intranet. I want this VM with a floating IP to have a fixed domain name.


But here comes the problem, Synalogy's DDNS seems to only use the IP of the NAS,
His original intention is to allow us to access our own NAS with a domain name anywhere.

My Nas already has a fixed IP, so I don't need DDNS service, but my VM needs it :p.

Fortunately, the configuration is not difficult at all, just Google it, and within a minute, I found that the configuration file of Synalogy NAS is placed in /etc/ddns.conf,
Moreover, updating the IP on the configuration file can update the A record of DDNS, so I immediately thought,
Then I just write bash to regularly update the IP of the configuration file, and it will be done.

The content of /etc/ddns.conf is as follows: (The actual content has been adjusted, the following is only for illustration)
#If you want to change DDNS Name, remember to change upnpd.c
# , remember to consider updating problem.
[Synology]
hostname=dodoro.myDS.me
passwd=############
net=MANUAL
status=service_ddns_normal
ip=36.229.6.29
service=true
username=myemail@example.corp
enable_heartbeat=yes
provider=Synology
ipv6=2001:b011:380c:1a4a:11:32ff:fe24:99ed

Then, this is a simple bash I wrote, which is used to update the IP of /etc/ddns.conf for dynamic domain name IP.
#!/bin/bash
old_ip=`grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /etc/ddns.conf`
#echo ${ip}
new_ip=`ssh e-course curl -s ip.ccc.tc`

sed -i "s/ip=${old_ip}/ip=${new_ip}/g" /etc/ddns.conf
This bash mainly performs the following things.
1. Obtain the old IP location of the ddns.conf configuration file, old_ip is the current ip set by ddns.
2. Connect to my VM through ssh, execute curl -s ip.ccc.tc, and use curl to obtain the external network IP of my VM (connect to the VM through OpenSSH public key authentication).
ip.ccc.tc is used by me to obtain external network ip, you should be able to use ifconfig.co to achieve the same effect.
3. Use the sed command to update the IP in ddns.conf to the latest location. That's it.

Finally, the tasks placed on the nas are scheduled to be checked every five minutes.


Finally, here is another little trick, if I have a domain name, I can set the cname,
We can use our own domain name to connect to the computer with floating IP. Below, I use the host command to query the location of e-course.app.
host -t a e-course.app
e-course.app is an alias for dodoro.myds.me.
dodoro.myds.me has address 36.229.6.29

As of this article, I am quite satisfied with the operation, and I will never type a domain name again, and the result is that I cannot connect to the host. :)


 

Tags: ddns Synology dns

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


Synology,NAS

Remove IP of Synology NAS Block via command line

In some cases, your IP may be locked by the Synology NAS, for example, the email host is installed on the Synology NAS, and the email password is incorrectly set. Or Synology did not correctly set the forward header of the real IP on the internal network. No matter what the reason is, we want to remove the locked IP through the command line.

ddns,pppoe

Truly free DDNS service

If you need to use DDNS, there are too many fake free DDNS on the Internet, you can really try this one, it is really free and easy to set up. https://www.duckdns.org/DDNS is also called dynamic DNS, which allows our floating IP to obtain a domain name. In this way, we can access our floating IP host through the domain name.

docker,Synology

How to modify the logging driver of Docker on Synolog NAS

On my Synolog Nas, a strange logging driver named db is running by default, how to modify it to a normal json-file? In Synolog's Nas, his Daemon config file is special, and it is placed in the /var/packages/Docker/etc/ directory. Called dockerd.json.