-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
138 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
lib, | ||
... | ||
}: | ||
let | ||
template = ownAs: '' | ||
local as ${toString ownAs}; | ||
enforce first as on; | ||
graceful restart on; | ||
long lived graceful restart on; | ||
advertise hostname on; | ||
prefer older on; | ||
# defaults | ||
enable route refresh on; | ||
interpret communities on; | ||
default bgp_local_pref 100; | ||
''; | ||
in | ||
{ | ||
mkPeerV4 = | ||
{ | ||
name, | ||
ownAs, | ||
remoteAs, | ||
ownIp, | ||
remoteIp, | ||
|
||
# bgp communities | ||
latency, | ||
bandwidth, | ||
crypto, | ||
transit, | ||
}: | ||
'' | ||
protocol bgp ${name}_4 { | ||
local as ${builtins.toString ownAs}; | ||
${template ownAs} | ||
neighbor ${remoteIp} as ${builtins.toString remoteAs}; | ||
source address ${ownIp}; | ||
ipv4 { | ||
import limit 9000 action block; | ||
import table on; | ||
import where dn_import_filter4(${toString latency}, ${toString bandwidth}, ${toString crypto}); | ||
export where dn_export_filter4(${toString latency}, ${toString bandwidth}, ${toString crypto}, ${lib.boolToString transit}); | ||
}; | ||
} | ||
''; | ||
mkPeerV6 = | ||
{ | ||
name, | ||
ownAs, | ||
remoteAs, | ||
ownIp, | ||
remoteIp, | ||
ownInterface, | ||
|
||
# bgp communities | ||
latency, | ||
bandwidth, | ||
crypto, | ||
transit, | ||
|
||
# whether ipv4 session should be configured for the ipv6 neighbor | ||
extendedNextHop, | ||
}: | ||
'' | ||
protocol bgp ${name}_6 { | ||
${template ownAs} | ||
${lib.optionalString extendedNextHop '' | ||
enable extended messages on; | ||
ipv4 { | ||
import limit 9000 action block; | ||
import table on; | ||
extended next hop on; | ||
import where dn_import_filter4(${toString latency}, ${toString bandwidth}, ${toString crypto}); | ||
export where dn_export_filter4(${toString latency}, ${toString bandwidth}, ${toString crypto}, ${lib.boolToString transit}); | ||
}; | ||
''} | ||
ipv6 { | ||
import limit 9000 action block; | ||
import table on; | ||
import where dn_import_filter6(${toString latency}, ${toString bandwidth}, ${toString crypto}); | ||
export where dn_export_filter6(${toString latency}, ${toString bandwidth}, ${toString crypto}, ${lib.boolToString transit}); | ||
}; | ||
neighbor ${remoteIp}%'${ownInterface}' as ${toString remoteAs}; | ||
source address ${ownIp}; | ||
} | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters