Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of implementing DDNS dynamic Domain name Resolution Service in LINUX

Shulou Source: shulou.com Published: 2022-06-03 05:44:52 09月21日 Update

Linux systems can write script commands to resolve dynamic domain names, and support dynamic domain name resolution for IPV4 and IPV6.

Go directly to the code:

Go to IPV4 first.

Sync

Old=$ (cat ip.asp)

Sleep 10

New=$ (ifconfig vlan2 | awk'/ inet/')

If ["$old"! = "$new"]

Then

Rm-rf ip.asp

Echo $new > ip.asp

Wget "http://main.meibu.com/ip/login.asp?name=abc.meibu.net&pwd=abc"

Rm login.asp*

Else

Echo "= = same!"

Fi

The variable new here is the new IP address new=$ (ifconfig vlan2 | awk'/ inet/'), which can get the native IP.

Compared with the last comparison, if the same is the same, the difference will be submitted to the parsing server, and the IP will be written to the file ip.asp for the next comparison.

And then on IPV6.

Sync

Old=$ (cat ips6.asp)

Sleep 10

New=$ (ifconfig vlan2 | awk'/ inet6/')

If ["$old"! = "$new"]

Then

Rm-rf ips6.asp

Echo $new > ips6.asp

Wget "http://v6.meibu.com/v6.asp?name=abc.noip.cn&pwd=abc"

Rm v6.asp*

Else

Echo "= = same!"

Fi

The variable new here is the new IPV6 address new=$ (ifconfig vlan2 | awk'/ inet6/'). You can get the native IPV6 address. If it is the same as the last comparison, it will end if it is different, and submit it to the parsing server. At the same time, write the IPV6 to the file ips6.asp for next comparison.

The abc.noip.cn&pwd=abc is changed to the domain name and password you applied for at each step.

Just make a timer or loop.

Tags: Domain name address dynamic service variable file server and the same native code command timer password system script loop support method real Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL OPPO Reno macOS Xiaomi