Community discussions

MikroTik App
 
User avatar
robtor
newbie
Topic Author
Posts: 45
Joined: Sat Dec 09, 2023 3:27 pm
Location: Germany, Hessen
Contact:

1und1 IONOS DNS Update-Script

Sat Feb 03, 2024 4:50 pm

Hello guys, with this thread I want to share my IPv6 Aware DNS update script that works with the IONOS API endpoint for domains registered at ionos.com. I still have some issues with updating the IPv6 configuration but this is more related to the configuration of my linux server. Maybe someone knows how to resolve this problem. For the others: Here's my script if you want to use it:
#=========================
# IONOS DNS updater script
#=========================

# Set IONOS api-key here
:local apikey "PLACE-API-KEY-HERE"

# Set pppoe interface for v4
:local pppoeint "pppoe-out1"

# Set DMZ interface for v6 here (There's only one host connected to this port -> Server within DMZ)
:local dmzint "ether7"


#==========================================

# Determine public ipv4 and v6 addresses
:local pubv4 [/ip/address/get [find where interface=$pppoeint] value-name=address]
:local pubv6

:do {
    :set pubv6 [/ipv6/neighbor/get [find interface=$dmzint && address~"^[^fe80]|^[^ff02]"] address]
} on-error={
    :log warning "Could not determine IPv6 address"
    :set pubv6 "e"
}

# Remove CIDR subnat from v4 address
:set pubv4 [:pick $pubv4 0 ([:len $pubv4] - 3)]

# Logging to console
:log info "IONOS DNS updating with IPv4=$pubv4 and IPv6=$pubv6"

# Build urls for making api key request

:local rawurl "https://ipv4.api.hosting.ionos.com/dns/v1/dyndns?"
:local paramurl

:if ($pubv6 = "e") do={
    :set paramurl ($rawurl."q=".$apikey."&ipv4=".$pubv4)
} else={
    :set paramurl ($rawurl."q=".$apikey."&ipv4=".$pubv4."&ipv6=".$pubv6)
}

:local result [/tool/fetch http-method=get mode=https url="$paramurl" as-value output=user]

:if ($result->"status" = "finished") do={
    :log info "IONOS DNS update successful"
    } else={
    :log warn "IONOS DNS update failed"
}
My issue with this script is that the public IPv6 Address retrieved via the
/ipv6/neighbor/get
command is sometimes outdated/deprecated. The linux machine itself lists it's new address after I got a new prefix assigned by my provider, but still has entries with the "deprecated" flag of the old addresses. Somehow It does not send out Neighbor Solicitation messages from the new address and thus the Router does not see the address with the new prefix. Any ideas on this?

For instance, here is the output of the ip -6 address command:
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2003:d9:d722:3602:449b:a59b:4114:ed37/64 scope global temporary dynamic
valid_lft 603444sec preferred_lft 84734sec
inet6 2003:d9:d722:3602:1efd:8ff:fe74:a984/64 scope global dynamic mngtmpaddr proto kernel_ra
valid_lft 2591958sec preferred_lft 604758sec
inet6 2003:d9:d725:ae02:c3d5:469b:9a8c:b6ba/64 scope global temporary deprecated dynamic
valid_lft 598861sec preferred_lft 0sec
inet6 2003:d9:d725:ae02:1efd:8ff:fe74:a984/64 scope global deprecated dynamic mngtmpaddr proto kernel_ra
The correct address is the first one in the list 2003:d9:d722:3602:449b:a59b:4114:ed37/64 but this one does not appear within the Router's Neighbors list. Only one of the old ones below with the "deprecated" flag. Any ideas on this? Do I have to set some special kernel parameters?

Who is online

Users browsing this forum: No registered users and 5 guests