update
This commit is contained in:
42
bird/filter/unet_filter.conf
Normal file
42
bird/filter/unet_filter.conf
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
function function_unet_import() {
|
||||||
|
if !unet_is_valid_network() then return false;
|
||||||
|
if is_unet_self_net() then return false;
|
||||||
|
bgp_large_community.add((UNET_ASN,200,0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function function_unet_export() {
|
||||||
|
if !unet_is_valid_network() then reject;
|
||||||
|
if source !~ [RTS_STATIC, RTS_BGP] then reject;
|
||||||
|
if bgp_large_community !~ [(UNET_ASN, 200,0)] then reject;
|
||||||
|
accept;
|
||||||
|
}
|
||||||
|
|
||||||
|
function function_unet_only_import() {
|
||||||
|
if !unet_is_valid_network_v4() then return false;
|
||||||
|
if is_unet_self_net() then return false;
|
||||||
|
bgp_large_community.add((UNET_ASN,200,0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function function_unet_only_export() {
|
||||||
|
if !unet_is_valid_network_v4() then return false;
|
||||||
|
if source !~ [RTS_STATIC, RTS_BGP] then return false;
|
||||||
|
if bgp_large_community !~ [(UNET_ASN, 200,0)] then return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function function_unet_ibgp_import() {
|
||||||
|
if bgp_large_community ~ [(UNET_ASN, 1,*)] then return false;
|
||||||
|
if !unet_is_valid_network() then return false;
|
||||||
|
if is_unet_self_net() then return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function function_unet_ibgp_export() {
|
||||||
|
if bgp_large_community ~ [(UNET_ASN, 1,*)] then return false;
|
||||||
|
if !unet_is_valid_network() then return false;
|
||||||
|
if is_unet_self_net() then return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -23,3 +23,11 @@ function is_unet_self_net() {
|
|||||||
else: print "is_unet_prefix: unexpected net.type ", net.type, " ", net; return false;
|
else: print "is_unet_prefix: unexpected net.type ", net.type, " ", net; return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function unet_is_valid_network() {
|
||||||
|
case net.type {
|
||||||
|
NET_IP4: return unet_is_valid_network_v4_allnet();
|
||||||
|
NET_IP6: return unet_is_voalid_net_v6();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,34 +3,14 @@ template bgp unet_bgp_up0 {
|
|||||||
local as UNET_ASN;
|
local as UNET_ASN;
|
||||||
ipv4 {
|
ipv4 {
|
||||||
table unet4;
|
table unet4;
|
||||||
import filter {
|
import filter {if !function_unet_import() then reject; accept; };
|
||||||
if !unet_is_valid_network_v4_allnet() then reject;
|
export filter {if !function_unet_export() then reject; accept; };
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
bgp_large_community.add((UNET_ASN,200,0));
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
export filter {
|
|
||||||
if !unet_is_valid_network_v4_allnet() then reject;
|
|
||||||
if source !~ [RTS_STATIC, RTS_BGP] then reject;
|
|
||||||
if bgp_large_community !~ [(UNET_ASN, 200,0)] then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
import limit 9000 action block;
|
import limit 9000 action block;
|
||||||
};
|
};
|
||||||
ipv6 {
|
ipv6 {
|
||||||
table unet6;
|
table unet6;
|
||||||
import filter {
|
import filter {if !function_unet_import() then reject; accept; };
|
||||||
if !unet_is_voalid_net_v6() then reject;
|
export filter {if !function_unet_export() then reject; accept; };
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
bgp_large_community.add((UNET_ASN,200,0));
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
export filter {
|
|
||||||
if !unet_is_voalid_net_v6() then reject;
|
|
||||||
if source !~ [RTS_STATIC, RTS_BGP] then reject;
|
|
||||||
if bgp_large_community !~ [(UNET_ASN, 200,0)] then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
import limit 9000 action block;
|
import limit 9000 action block;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -40,18 +20,8 @@ template bgp unet_bgp_up1 {
|
|||||||
local as UNET_ASN;
|
local as UNET_ASN;
|
||||||
ipv4 {
|
ipv4 {
|
||||||
table unet4;
|
table unet4;
|
||||||
import filter {
|
import filter {if !function_unet_only_import() then reject; accept; };
|
||||||
if !unet_is_valid_network_v4() then reject;
|
export filter {if !function_unet_only_export() then reject; accept; };
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
bgp_large_community.add((UNET_ASN,200,0));
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
export filter {
|
|
||||||
if !unet_is_valid_network_v4() then reject;
|
|
||||||
if source !~ [RTS_STATIC, RTS_BGP] then reject;
|
|
||||||
if bgp_large_community !~ [(UNET_ASN, 200,0)] then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
import limit 9000 action block;
|
import limit 9000 action block;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -65,34 +35,14 @@ template bgp unet_ibgp {
|
|||||||
table unet4;
|
table unet4;
|
||||||
next hop self;
|
next hop self;
|
||||||
gateway direct;
|
gateway direct;
|
||||||
import filter {
|
import filter {if !function_unet_ibgp_import() then reject; accept; };
|
||||||
if bgp_large_community ~ [(UNET_ASN, 1,*)] then reject;
|
export filter {if !function_unet_ibgp_export() then reject; accept; };
|
||||||
if !unet_is_valid_network_v4_allnet() then reject;
|
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
export filter {
|
|
||||||
if bgp_large_community ~ [(UNET_ASN, 1,*)] then reject;
|
|
||||||
if !unet_is_valid_network_v4_allnet() then reject;
|
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
ipv6 {
|
ipv6 {
|
||||||
table unet6;
|
table unet6;
|
||||||
next hop self;
|
next hop self;
|
||||||
gateway direct;
|
gateway direct;
|
||||||
import filter {
|
import filter {if !function_unet_ibgp_import() then reject; accept; };
|
||||||
if bgp_large_community ~ [(UNET_ASN, 1,*)] then reject;
|
export filter {if !function_unet_ibgp_export() then reject; accept; };
|
||||||
if !unet_is_voalid_net_v6() then reject;
|
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
export filter {
|
|
||||||
if bgp_large_community ~ [(UNET_ASN, 1,*)] then reject;
|
|
||||||
if !unet_is_voalid_net_v6() then reject;
|
|
||||||
if is_unet_self_net() then reject;
|
|
||||||
accept;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,12 @@ git clone https://git.nia.ink/brnet/bird_config.git
|
|||||||
rm /etc/bird/filter/*.conf
|
rm /etc/bird/filter/*.conf
|
||||||
mv ./bird_config/bird/filter/*.conf /etc/bird/filter/
|
mv ./bird_config/bird/filter/*.conf /etc/bird/filter/
|
||||||
|
|
||||||
|
rm /etc/bird/function/*.conf
|
||||||
|
mv ./bird_config/bird/function/*.conf /etc/bird/function/
|
||||||
|
|
||||||
|
rm /etc/bird/template/*.conf
|
||||||
|
mv ./bird_config/bird/template/*.conf /etc/bird/template/
|
||||||
|
|
||||||
|
|
||||||
birdc c
|
birdc c
|
||||||
cd
|
cd
|
||||||
|
|||||||
Reference in New Issue
Block a user