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?
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. :)
No Comment
Post your comment