From b903422ec641bb34fda48e1d50118e6bc3bb6af3 Mon Sep 17 00:00:00 2001 From: gaoyuheng Date: Sat, 23 May 2026 17:35:37 +0800 Subject: [PATCH] 1 --- bird/conf/dn42.conf | 14 ------ bird/function/tables.conf | 1 - bird/function/unet.conf | 1 - bird/net/dn42.conf | 19 +-------- bird/net/unet.conf | 12 ------ bird/template/dn42.conf | 85 ++++++++++++------------------------- bird/template/dn42_new.conf | 67 ----------------------------- update.sh | 11 ++--- 8 files changed, 35 insertions(+), 175 deletions(-) delete mode 100644 bird/template/dn42_new.conf diff --git a/bird/conf/dn42.conf b/bird/conf/dn42.conf index 349163d..f4cae6c 100644 --- a/bird/conf/dn42.conf +++ b/bird/conf/dn42.conf @@ -11,18 +11,4 @@ protocol static route_dn42_export_v4 { }; export none; }; -} - -protocol static route_dn42_export_v6 { - route fde8:936e:ee29::/48 reject; - ipv6 { - table dn42v6; - import filter { - bgp_large_community.add((DN42_ASN,3,0));# 不允许导出到内核 - bgp_large_community.add((DN42_ASN,1,0));# 不允许传输到ibgp - bgp_large_community.add((DN42_ASN,200,0));# 传输到Ebgp - accept; - }; - export none; - }; } \ No newline at end of file diff --git a/bird/function/tables.conf b/bird/function/tables.conf index 7eaf822..b6dc5b6 100644 --- a/bird/function/tables.conf +++ b/bird/function/tables.conf @@ -3,7 +3,6 @@ ipv6 table t102v6; ipv4 table inet4; ipv6 table inet6; ipv4 table dn42v4; -ipv6 table dn42v6; ipv4 table unet4; ipv6 table unet6; ipv4 table ospf4; diff --git a/bird/function/unet.conf b/bird/function/unet.conf index 99485c2..d07d4fd 100644 --- a/bird/function/unet.conf +++ b/bird/function/unet.conf @@ -13,7 +13,6 @@ function unet_is_valid_network_v4_allnet(){ function unet_is_voalid_net_v6(){ if is_self_net() then return true; - if is_dn42_self_net() then return true; return false; } diff --git a/bird/net/dn42.conf b/bird/net/dn42.conf index 1d247b3..f02e0c7 100644 --- a/bird/net/dn42.conf +++ b/bird/net/dn42.conf @@ -1,29 +1,14 @@ protocol pipe dn42v4_sync { table dn42v4; - peer table t102v4; + peer table master4; export filter { if bgp_large_community ~ [(DN42_ASN, 3,*)] then reject; if !is_dn42_prefix() then reject; bgp_community.empty; bgp_large_community.empty; - bgp_large_community.add((UNET_ASN,10,10204)); + bgp_large_community.add((UNET_ASN,10,4)); krt_prefsrc = DN42_V4_kernel; accept; }; import none; -} - -protocol pipe dn42v6_sync { - table dn42v6; - peer table t102v6; - export filter { - if bgp_large_community ~ [(DN42_ASN, 3,*)] then reject; - if !is_dn42_prefix() then reject; - bgp_community.empty; - bgp_large_community.empty; - bgp_large_community.add((UNET_ASN,10,10206)); - krt_prefsrc = DN42_V6_kernel; - accept; - }; - import none; } \ No newline at end of file diff --git a/bird/net/unet.conf b/bird/net/unet.conf index 3c73bf5..af805aa 100644 --- a/bird/net/unet.conf +++ b/bird/net/unet.conf @@ -38,18 +38,6 @@ protocol pipe unet4_dn42v4_sync { import none; } -protocol pipe unet6_dn42v6_sync { - table unet6; - peer table dn42v6; - export filter { - if bgp_large_community ~ [(UNET_ASN, 3,*)] then reject; - if !is_dn42_prefix() then reject; - accept; - }; - import none; -} - - # 剩下的进入master (只有V4) protocol pipe unet4_sync { table unet4; diff --git a/bird/template/dn42.conf b/bird/template/dn42.conf index 1db8e48..aa32fce 100644 --- a/bird/template/dn42.conf +++ b/bird/template/dn42.conf @@ -1,40 +1,24 @@ -template bgp dn42_bgp_up { +template bgp dn42_up0_new { graceful restart; local as DN42_ASN; ipv4 { table dn42v4; - import filter { - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; - export filter { - if !is_dn42_prefix() then reject; - if source !~ [RTS_STATIC, RTS_BGP] then reject; - if bgp_large_community !~ [(DN42_ASN, 200,0)] then reject; - accept; - }; - import limit 9000 action block; - }; - - ipv6 { - table dn42v6; - import filter { - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; - export filter { - if !is_dn42_prefix() then reject; - if source !~ [RTS_STATIC, RTS_BGP] then reject; - if bgp_large_community !~ [(DN42_ASN, 200,0)] then reject; - accept; - }; - import limit 9000 action block; + import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; + export filter {if !function_dn42_bgp_export_to_upstream0() then reject; accept; }; }; } -template bgp dn42_ibgp { +template bgp dn42_up1_new { + graceful restart; + local as DN42_ASN; + ipv4 { + table dn42v4; + import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; + export filter {if !function_dn42_bgp_export_to_upstream1() then reject; accept; }; + }; +} + +template bgp dn42_ibgp_new { graceful restart; local as DN42_ASN; med metric; @@ -43,34 +27,19 @@ template bgp dn42_ibgp { table dn42v4; next hop self; gateway direct; - import filter { - if bgp_large_community ~ [(DN42_ASN, 1,*)] then reject; - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; - export filter { - if bgp_large_community ~ [(DN42_ASN, 1,*)] then reject; - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; + import filter {if !function_dn42_ibgp_import() then reject; accept; }; + export filter {if !function_dn42_ibgp_export() then reject; accept; }; }; - ipv6 { - table dn42v6; - next hop self; - gateway direct; - import filter { - if bgp_large_community ~ [(DN42_ASN, 1,*)] then reject; - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; - export filter { - if bgp_large_community ~ [(DN42_ASN, 1,*)] then reject; - if !is_dn42_prefix() then reject; - if is_dn42_self_net() then reject; - accept; - }; +} + + +template bgp dn42_ibgp_mp_new { + graceful restart; + local as DN42_ASN; + med metric; + ipv4 { + table dn42v4; + import filter {if !function_dn42_ibgp_import() then reject; accept; }; + export filter {if !function_dn42_ibgp_export() then reject; accept; }; }; } \ No newline at end of file diff --git a/bird/template/dn42_new.conf b/bird/template/dn42_new.conf deleted file mode 100644 index eeac406..0000000 --- a/bird/template/dn42_new.conf +++ /dev/null @@ -1,67 +0,0 @@ -template bgp dn42_up0_new { - graceful restart; - local as DN42_ASN; - ipv4 { - table dn42v4; - import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; - export filter {if !function_dn42_bgp_export_to_upstream0() then reject; accept; }; - }; - ipv6 { - table dn42v6; - import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; - export filter {if !function_dn42_bgp_export_to_upstream0() then reject; accept; }; - }; -} - -template bgp dn42_up1_new { - graceful restart; - local as DN42_ASN; - ipv4 { - table dn42v4; - import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; - export filter {if !function_dn42_bgp_export_to_upstream1() then reject; accept; }; - }; - ipv6 { - table dn42v6; - import filter {if !function_dn42_bgp_import_from_upstream() then reject; accept; }; - export filter {if !function_dn42_bgp_export_to_upstream1() then reject; accept; }; - }; -} - -template bgp dn42_ibgp_new { - graceful restart; - local as DN42_ASN; - med metric; - direct; - ipv4 { - table dn42v4; - next hop self; - gateway direct; - import filter {if !function_dn42_ibgp_import() then reject; accept; }; - export filter {if !function_dn42_ibgp_export() then reject; accept; }; - }; - ipv6 { - table dn42v6; - next hop self; - gateway direct; - import filter {if !function_dn42_ibgp_import() then reject; accept; }; - export filter {if !function_dn42_ibgp_export() then reject; accept; }; - }; -} - - -template bgp dn42_ibgp_mp_new { - graceful restart; - local as DN42_ASN; - med metric; - ipv4 { - table dn42v4; - import filter {if !function_dn42_ibgp_import() then reject; accept; }; - export filter {if !function_dn42_ibgp_export() then reject; accept; }; - }; - ipv6 { - table dn42v6; - import filter {if !function_dn42_ibgp_import() then reject; accept; }; - export filter {if !function_dn42_ibgp_export() then reject; accept; }; - }; -} \ No newline at end of file diff --git a/update.sh b/update.sh index 7276b45..365a064 100644 --- a/update.sh +++ b/update.sh @@ -3,14 +3,15 @@ cd git clone https://git.nia.ink/brnet/bird_config.git -rm /etc/bird/bird.conf -mv ./bird_config/bird/bird.conf /etc/bird/bird.conf - rm /etc/bird/net/*.conf mv ./bird_config/bird/net/*.conf /etc/bird/net/ +rm /etc/bird/net/ospf.conf* -rm /etc/bird/template/*.conf -mv ./bird_config/bird/template/*.conf /etc/bird/template/ +rm /etc/bird/template/dn42*.conf +mv ./bird_config/bird/template/dn42.conf /etc/bird/template/ + +rm /etc/bird/function/*.conf +mv ./bird_config/bird/function/*.conf /etc/bird/function/ birdc c cd