Skip to content

Instantly share code, notes, and snippets.

@m13253
Last active November 5, 2022 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m13253/6d10fdf1c0ab0df33aa4be7f5171e0ab to your computer and use it in GitHub Desktop.
Save m13253/6d10fdf1c0ab0df33aa4be7f5171e0ab to your computer and use it in GitHub Desktop.
BIRD 2.0 utility for DN42 related operations
# BIRD 2.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);
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