You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# WAN0_GW_IPV4_ADDRESS: The IPv4 address of the router's WAN0 gateway
95
+
# 设置自定义变量WAN0_GW_IPV4_ADDRESS为路由器WAN0网关IPv4地址
96
+
WAN0_GW_IPV4_ADDRESS="$(ip address show dev "${WAN0_GW_IFNAME}"| /opt/bin/sed -E -n -e 's/^[[:space:]]*inet[[:space:]]*([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*).*/\1/p')"
97
+
#
98
+
# WAN0_GW_IPV6_ADDRESS: The IPv6 address of the router's WAN0 gateway
99
+
# 设置自定义变量WAN0_GW_IPV6_ADDRESS为路由器WAN0网关IPv6地址
100
+
#WAN0_GW_IPV6_ADDRESS="$()"
101
+
}
102
+
#
103
+
########## END ##########
104
+
#
105
+
#
106
+
########## TEST CONNECTION AND UPDATE DNS RECORD ##########
77
107
#
78
-
# FAIL_DATE: The date on which the 1st fail test of IP address happens
79
-
#设置自定义变量FAIL_DATE为首次IP地址测试失败的发生日期
108
+
# FAIL_DATE: The date of the first failure
109
+
#设置自定义变量FAIL_DATE为首次失败的时间
80
110
FAIL_DATE=""
81
111
#
82
-
# FAIL_COUNT: The count of fail tests of IP address
if [ -z"${RESULT_1_OF_CONNECTION_TEST}"] || [ -z"${RESULT_2_OF_CONNECTION_TEST}"] || [ -z"${RESULT_3_OF_CONNECTION_TEST}"]
93
125
then
94
-
FAIL_DATE=""
95
-
FAIL_COUNT=0
126
+
getIPAddress
96
127
#
97
-
break
128
+
if [ -n"${EXTERNAL_IPV4_ADDRESS}" ] && [ -n"${WAN0_GW_IPV4_ADDRESS}" ]
129
+
then
130
+
FAIL_DATE=""
131
+
FAIL_COUNT=0
132
+
#
133
+
break
134
+
#
135
+
else
136
+
if [ -z"${FAIL_DATE}" ]
137
+
then
138
+
FAIL_DATE="$(/opt/bin/date "+%F %T")"
139
+
fi
140
+
#
141
+
FAIL_COUNT=$((${FAIL_COUNT}+1))
142
+
#
143
+
if [ ${FAIL_COUNT}-ge 3 ]
144
+
then
145
+
/opt/bin/echo -e "FAILURE: [${FAIL_DATE}] CAN NOT GET IP ADDRESS"| /opt/bin/tee -a "${LOGFILE}"
146
+
#
147
+
exit 2
148
+
fi
149
+
#
150
+
/opt/bin/sleep 5
151
+
fi
98
152
#
99
153
else
100
154
if [ -z"${FAIL_DATE}" ]
@@ -115,56 +169,40 @@ do
115
169
fi
116
170
done
117
171
#
118
-
# Check if the IP address of the router's WAN port is equal to the public IP address. If the answer is yes, update DNS record and exit. And if the answer is no, repeat the test up to 3 times. If all the answers are no, send an email as notification and exit.
# Check if the IP address of the router's WAN0 gateway is equal to the external IP address. If the answer is yes, update DNS record and exit. And if the answer is no, repeat the test up to 3 times. If all the answers are no, send an email as notification and exit.
# WAN_IPV4_ADDRESS: The IPv4 address of the router's WAN port
132
-
# 设置自定义变量WAN_IPV4_ADDRESS为路由器WAN口IPv4地址
133
-
WAN_IPV4_ADDRESS="$(ip address show dev "${WAN0_GW_IFNAME}"| /opt/bin/sed -E -n -e 's/^[[:space:]]*inet[[:space:]]*([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*).*/\1/p')"
134
-
#
135
-
# WAN_IPV6_ADDRESS: The IPv6 address of the router's WAN port
136
-
# 设置自定义变量WAN_IPV6_ADDRESS为路由器WAN口IPv6地址
137
-
#WAN_IPV6_ADDRESS="$()"
138
-
#
139
-
# Check if ${WAN_IPV4_ADDRESS} is equal to ${PUBLIC_IPV4_ADDRESS}
0 commit comments