-
Notifications
You must be signed in to change notification settings - Fork 0
/
noip DDNS update without WAN interface.txt
103 lines (85 loc) · 3.23 KB
/
noip DDNS update without WAN interface.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#Define no.ip setting:
#================================================
:local NoipUsername ""
:local NoipPassword ""
:local NoipDomain ""
:local UpdateIPv4 true
:local UpdateIPv6 false
:local LogPrefix "no.ip DDNS:"
#================================================
#If you don't understand the following programs, not recommended to modify:
#------------------------------------------------------------------------------------------
#Define IP variable
:local NoipDDNSPreviousIPv4
:local NoipDDNSPreviousIPv6
:local IPChanged false
:local IPv4Address
:local IPv6Address
:local IPv4TmpStr
:local IPv6TmpStr
:if ($UpdateIPv4) do={
#Define variable preset
:if ([ :typeof $NoipDDNSPreviousIPv4 ] = nil ) do={ $NoipDDNSPreviousIPv4 "0.0.0.0" }
#Get IPv4 address
/tool fetch url="https://api.ipify.org" mode=http dst-path=("ipv4_address")
:delay 1
#Get file contents
:set IPv4Address [ /file get "ipv4_address" contents]
#Delete file
:local filename [ /file find name="ipv4_address"]
/file remove $filename
#Determine whether to update the IPv4
:if ([ :typeof $IPv4Address ] = nil ) do={
:log error ($LogPrefix." IPv4 address not obtained")
} else={
:if ($IPv4Address != $NoipDDNSPreviousIPv4) do={
:set IPv4TmpStr "&myip=$IPv4Address"
:set IPChanged true
}
}
}
:if ($UpdateIPv6) do={
#Define variable preset
:if ([ :typeof $NoipDDNSPreviousIPv6 ] = nil ) do={ $NoipDDNSPreviousIPv6 "::" }
#Get IPv6 address
/tool fetch url="https://api64.ipify.org" mode=http dst-path=("ipv6_address")
:delay 1
#Get file contents
:set IPv6Address [ /file get "ipv6_address" contents]
#Delete file
:local filenames [ /file find name="ipv6_address"]
/file remove $filenames
#Determine whether to update the IPv6
:if ([ :typeof $IPv6Address ] = nil ) do={
:log error ($LogPrefix." IPv6 address not obtained")
} else={
:if ($IPv6Address != $NoipDDNSPreviousIPv6) do={
:set IPv6TmpStr "&myipv6=$IPv6Address"
:set IPChanged true
}
}
}
#update DDNS IP
:if ($IPChanged) do={
:local url ("https://dynupdate.no-ip.com/nic/update?hostname=$NoipDomain".$IPv4TmpStr.$IPv6TmpStr)
/tool fetch url=($url) user=$NoipUsername password=$NoipPassword mode=http dst-path=("noip-ddns-update-$NoipDomain-info")
:delay 1
#File content
:local filestr [ /file get "noip-ddns-update-$NoipDomain-info" contents]
#Delete file
:local filename [ /file find name="noip-ddns-update-$NoipDomain-info"]
/file remove $filename
#Update success or not
:if ( [ :find $filestr "good"] = "0" || [ :find $filestr "nochg"] = "0" ) do={
:log info ($LogPrefix." update success")
:if ($UpdateIPv4 && [ :typeof $IPv4Address ] != nil && [ :typeof $IPv4TmpStr ] != nil ) do={
:set NoipDDNSPreviousIPv4 $IPv4Address
}
:if ($UpdateIPv6 && [ :typeof $IPv6Address ] != nil && [ :typeof $IPv6TmpStr ] != nil ) do={
:set NoipDDNSPreviousIPv6 $IPv6Address
}
} else={
:log error ($LogPrefix." fail to update")
}
}
#------------------------------------------------------------------------------------------