Skip to content

Instantly share code, notes, and snippets.

@m13253
Last active June 22, 2025 13:03
Show Gist options
  • Select an option

  • Save m13253/6d10fdf1c0ab0df33aa4be7f5171e0ab to your computer and use it in GitHub Desktop.

Select an option

Save m13253/6d10fdf1c0ab0df33aa4be7f5171e0ab to your computer and use it in GitHub Desktop.
BIRD 3.0 utility for DN42 related operations
# BIRD 3.0 utility for DN42 related operations
# To be used with:
# include "bird-dn42-util.conf";
# in bird.conf main configuration file.
function reset_origin (int transit_; int origin)
{
bgp_path.empty;
bgp_path.prepend(origin);
bgp_path.prepend(transit_); # "transit" is a keyword since BIRD 3.0
accept;
}
function mix_dn42 (int dn42_asn)
{
if net ~ [ 172.20.0.0/14+ ] || net ~ [ fd00::/8+ ] then {
bgp_path.filter([ 64600..64855, 76100..76199, 4242420000..4242429999 ]);
if bgp_path.first != dn42_asn then bgp_path.prepend(dn42_asn);
}
accept;
}
filter only_dn42
{
if net ~ [ 172.20.0.0/14{15,31} ] || net ~ [ fd00::/8{16,48} ] then accept;
reject;
}
#!/bin/bash
AS=(
AS64496
AS64497
AS-SET-EXAMPLE
)
set -e
[ "$(id -u)" = 0 ] || exec sudo -- "$0"
OUTPUT="$(mktemp)"
for as in "${AS[@]}"
do
bgpq4 -6Ab -l "define ${as//-/_}" -R 48 -- "$as" | tee -a -- "$OUTPUT"
done
chmod 0644 -- "$OUTPUT"
mv -- "$OUTPUT" filters.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment