Skip to content

Commit e7995fa

Browse files
committed
update-tunnelbroker: get public address from website
This is a good condidate: https://showipv6.de/ We can drop the cloud code, which seems to be unreliable in somd situations.
1 parent c95cbdb commit e7995fa

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

doc/update-tunnelbroker.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ The configuration goes to interface's comment:
3333
You should know you user name from login. The `id` is the tunnel's numeric
3434
id, `pass` is the *update key* found on the tunnel's advanced tab.
3535

36-
Also enabling dynamic DNS in Mikrotik cloud is required:
37-
38-
/ip/cloud/set ddns-enabled=yes;
39-
4036
See also
4137
--------
4238

update-tunnelbroker

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@
1717
:global LogPrintExit2;
1818
:global ParseKeyValueStore;
1919

20-
:if ([ /ip/cloud/get ddns-enabled ] != true) do={
21-
$LogPrintExit2 error $0 ("IP cloud DDNS is not enabled.") true;
20+
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false || \
21+
[ $CertificateAvailable "R3" ] = false) do={
22+
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
2223
}
2324

24-
# Get the current ip address from cloud
25-
/ip/cloud/force-update;
26-
:while ([ /ip/cloud/get status ] != "updated") do={
27-
:delay 1s;
25+
:local PublicAddress;
26+
:do {
27+
:set PublicAddress ([ /tool/fetch check-certificate=yes-without-crl \
28+
"https://ipv4.showipv6.de/short" output=user as-value ]->"data");
29+
} on-error={
30+
$LogPrintExit2 error $0 ("Failed getting public address.") true;
31+
}
32+
33+
:if ([ :len [ /ip/address find where address~("^" . $PublicAddress . "/") ] ] < 1) do={
34+
$LogPrintExit2 warning $0 ("The address " . $PublicAddress . " is not configured on your device. NAT by ISP?") false;
2835
}
29-
:local PublicAddress [ /ip/cloud/get public-address ];
3036

3137
:foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={
3238
:local InterfaceVal [ /interface/6to4/get $Interface ];
@@ -36,9 +42,6 @@
3642
:local Success false;
3743
:local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ];
3844

39-
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
40-
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
41-
}
4245
$LogPrintExit2 info $0 ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $PublicAddress) false;
4346
:while ($I < 3 && $Success = false) do={
4447
:do {

0 commit comments

Comments
 (0)