Skip to content

Instantly share code, notes, and snippets.

@ge0rg
Created July 18, 2026 22:20
Show Gist options
  • Select an option

  • Save ge0rg/568d8ba77ab9ffc015e9103ccbc8fc91 to your computer and use it in GitHub Desktop.

Select an option

Save ge0rg/568d8ba77ab9ffc015e9103ccbc8fc91 to your computer and use it in GitHub Desktop.
Print the active route numbers for each BGP-over-WireGuard tunnel (DN42)
# function to format-print name ($1), count ($2) and percentage of total ($3)
:local format do={ :put ($1 . ": " . $2 . " (" . ((100*$2)/$3) . "%)"); }
:local total [ /ipv6/route/print count-only as-value where active bgp ]
$format "total" $total $total
# iterate all wireguard interfaces matching "wg-dn42-"
:foreach interface in=[/interface/wireguard/print proplist=name as-value where name ~ "wg-dn42-" ] \
do={
:local ifname ($interface->"name")
# count and print the active routes from BGP going through *@ifname
:local matches [ /ipv6/route/print count-only as-value where gateway ~ "*" . $ifname active bgp ]
$format $ifname $matches $total
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment