18 กุมภาพันธ์ 2567

Mikrotik persist route to wireguard server for dynamic wan

Persist route to wireguard server for dynamic wan in case of setting default route via wireguard
 
 
DHCP client script
 
:if ($bound=1) do={
    :ip route remove [/ip route find comment="route-wireguard-wan"]
    :ip route add distance=5 gateway=$"gateway-address" dst-address="1.2.3.4/32" scope=30  target-scope=10  comment="route-wireguard-wan"
} else={
    :ip route remove [/ip route find comment="route-wireguard-wan"]
}