Skip to content

Commit

Permalink
replace accept_local with static BGP communities
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Nov 8, 2020
1 parent 8185dca commit f6beedc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
38 changes: 21 additions & 17 deletions templates/global.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,19 @@ define ASN = {{ .Asn }};
router id {{ .RouterId }};

{{ if .OriginSet4 -}}
define LOCAL_v4 = [
{{ BirdSet .OriginSet4 }}
];

protocol static static4 {
ipv4;
{{- range $i, $prefix := .OriginSet4 }}
route {{ $prefix }} reject;
route {{ $prefix }} reject { bgp_large_community.add((ASN,0,100)); };
{{- end }}
}
{{- end }}

{{ if .OriginSet6 -}}
define LOCAL_v6 = [
{{ BirdSet .OriginSet6 }}
];

protocol static static6 {
ipv6;
{{- range $i, $prefix := .OriginSet6 }}
route {{ $prefix }} reject;
route {{ $prefix }} reject { bgp_large_community.add((ASN,0,100)); };
{{- end }}
}
{{- end }}
Expand All @@ -39,16 +31,20 @@ timeformat route iso long;
log syslog all;

protocol device {};

protocol direct {
ipv4;
ipv6;
}
protocol direct { ipv4; ipv6; }

protocol kernel {
scan time 10;
{{ if .OriginSet4 -}}
ipv4 { export all; };
ipv4 {
import filter {
if (net ~ [
{{ BirdSet .OriginSet4 }}
]) then bgp_large_community.add((ASN,0,100));
accept;
};
export all;
};
{{- else }}
ipv4 { export none; };
{{ end }}
Expand All @@ -57,7 +53,15 @@ protocol kernel {
protocol kernel {
scan time 10;
{{ if .OriginSet6 -}}
ipv6 { export all; };
ipv6 {
import filter {
if (net ~ [
{{ BirdSet .OriginSet6 }}
]) then bgp_large_community.add((ASN,0,100));
accept;
};
export all;
};
{{- else }}
ipv6 { export none; };
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion templates/peer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protocol bgp {{ $peer.Name }}v{{ $af }}_{{ $i }} {
{{ $peer.PreExport -}}

{{- if or $global.OriginSet4 $global.OriginSet6 }}
accept_local(); # Originated
if ((ASN,0,100) ~ bgp_large_community) then accept; # Originated
{{ end -}}

{{ if eq $peer.Type "upstream" -}}
Expand Down

0 comments on commit f6beedc

Please sign in to comment.