Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define ROUTER_ID = 185.66.192.3;
- define AS_FFRL = 201701;
- define METRO_IDENTIFIER = 195;
- define ANNOUNCE_ALL = 300;
- define GLOBAL_ROUTE = (5093,200);
- define METRO_ROUTE = (5093,201);
- define BERLIN_ROUTE = (5093,195);
- define FRANKFURT_ROUTE = (5093,194);
- define DUESSELDORF_ROUTE = (5093,193);
- define AGGREGATE_ROUTE = (5093,191);
- define ROUTE_ORIGIN = (5093,195);
- define DRAINED = 0;
- define METROIZED = 0;
- router id 185.66.192.3;
- log syslog all;
- graceful restart wait 300;
- function is_our_net () {
- return net ~ [ 185.66.192.0/22+ ];
- }
- protocol kernel {
- scan time 10;
- import all;
- export all;
- }
- protocol static {
- #route 0.0.0.0/0 unreachable;
- route 185.66.195.0/24 unreachable;
- route 185.66.192.0/22 unreachable;
- }
- protocol device {
- scan time 10;
- }
- protocol ospf IGP {
- import all;
- export none;
- area 0.0.0.0 {
- interface "lo" {
- stub yes;
- };
- # X-Link bb-b.ber
- interface "eth4" {
- type broadcast;
- cost 1;
- };
- };
- }
- ################################################################################
- # Peering Policy #
- ################################################################################
- function community_in() {
- bgp_local_pref = 10000;
- bgp_med = 0;
- }
- filter drain {
- reject;
- }
- filter ibgp_in {
- if (GLOBAL_ROUTE ~ bgp_community) then {
- accept;
- }
- if (METRO_ROUTE ~ bgp_community) then {
- if (ROUTE_ORIGIN ~ bgp_community) then {
- accept;
- }
- else {
- bgp_local_pref = 5;
- accept;
- }
- }
- accept;
- }
- function peer_ip_filter_in() {
- if DRAINED = 1 then
- return 0;
- if net ~ [
- 10.0.0.0/8{8,32},
- 172.16.0.0/12{8,32},
- 192.168.0.0/16{16,32},
- 169.254.0.0/16{16,32},
- 224.0.0.0/3{3,32},
- 185.66.192.0/22{22,32},
- 100.64.0.0/10{10,32},
- 0.0.0.0/8{8,32},
- 127.0.0.0/8{8,32},
- 192.0.0.0/24{24,32},
- 198.18.0.0/15{15,32},
- 198.51.100.0/24{24,32},
- 203.0.113.0/24{24,32},
- 240.0.0.0/4{4,32},
- 255.255.255.255/32,
- 0.0.0.0/0
- ] then {
- return 0;
- }
- if net ~ [ 0.0.0.0/0{8,24} ] then {
- return 1;
- }
- return 0;
- }
- function peer_ip_filter_out() {
- if DRAINED = 1 then
- return 0;
- if net ~ [
- 185.66.192.0/22{22,24}
- ] then {
- return 1;
- }
- return 0;
- }
- function modify_originated_routes()
- {
- bgp_path.empty;
- if net = 185.66.192.0/22 then {
- bgp_community.add(AGGREGATE_ROUTE);
- bgp_community.add(BERLIN_ROUTE);
- return true;
- }
- if net = 185.66.195.0/24 then {
- bgp_community.add(METRO_ROUTE);
- bgp_community.add(BERLIN_ROUTE);
- return true;
- }
- return true;
- }
- function ebgp_out(string rt_scope)
- int path_prepend;
- {
- if peer_ip_filter_out() = 0 then {
- return 0;
- }
- modify_originated_routes();
- path_prepend = 0;
- if "global-transit" = rt_scope then {
- path_prepend = 1;
- }
- if "metro-transit" = rt_scope then {
- path_prepend = 1;
- }
- if path_prepend = 1 then {
- bgp_path.prepend(AS_FFRL);
- bgp_path.prepend(AS_FFRL);
- bgp_path.prepend(AS_FFRL);
- }
- if ("metro-transit" = rt_scope) || ("metro-peering" = rt_scope) then {
- if METROIZED = 0 then {
- if (AGGREGATE_ROUTE ~ bgp_community) then {
- return 1;
- }
- }
- else {
- if (AGGREGATE_ROUTE ~ bgp_community) then {
- return 0;
- }
- }
- if (ROUTE_ORIGIN ~ bgp_community) then {
- return 1;
- }
- return 0;
- }
- if "global-transit" = rt_scope || "global-peering" = rt_scope then {
- if METROIZED = 0 then {
- if (AGGREGATE_ROUTE ~ bgp_community) then {
- return 1;
- }
- if (METRO_ROUTE ~ bgp_community) then {
- return 1;
- }
- }
- else {
- if (AGGREGATE_ROUTE ~ bgp_community) then {
- return 0;
- }
- }
- if (ROUTE_ORIGIN ~ bgp_community) then {
- return 1;
- }
- return 0;
- }
- return 0;
- }
- function ebgp_in(string rt_scope)
- int lpref;
- int rt_med;
- int metroized;
- {
- if peer_ip_filter_in() = 0 then {
- return 0;
- }
- if "global-transit" = rt_scope then
- lpref = 500; rt_med = 0; metroized = 0;
- if "metro-transit" = rt_scope then
- lpref = 500; rt_med = 0; metroized = 1;
- if "global-peer" = rt_scope then
- lpref = 1000; rt_med = 0; metroized = 0;
- if "metro-peer" = rt_scope then
- lpref = 1000; rt_med = 0; metroized = 1;
- if "px-global-peer" = rt_scope then
- lpref = 1000; rt_med = 100; metroized = 0;
- if "px-metro-peer" = rt_scope then
- lpref = 1000; rt_med = 100; metroized = 1;
- if "px-global-backup-peer" = rt_scope then
- lpref = 1000; rt_med = 500; metroized = 0;
- if "px-metro-backup-peer" = rt_scope then
- lpref = 1000; rt_med = 500; metroized = 1;
- if "route-server" = rt_scope then
- lpref = 1000; rt_med = 1000; metroized = 0;
- bgp_local_pref = lpref;
- bgp_med = rt_med;
- if metroized = 1 then {
- bgp_community.add(METRO_ROUTE);
- }
- else {
- if METROIZED = 1 then {
- bgp_community.add(METRO_ROUTE);
- }
- else {
- bgp_community.add(GLOBAL_ROUTE);
- }
- }
- bgp_community.add(BERLIN_ROUTE);
- return 1;
- }
- filter global_transit_in {
- if ebgp_in("global-transit") = 1 then
- accept;
- reject;
- }
- filter metro_transit_in {
- if ebgp_in("metro-transit") = 1 then
- accept;
- reject;
- }
- filter global_peer_in {
- if ebgp_in("global-peer") = 1 then
- accept;
- reject;
- }
- filter metro_peer_in {
- if ebgp_in("metro-peer") = 1 then
- accept;
- reject;
- }
- filter px_global_peer_in {
- if ebgp_in("px-global-peer") = 1 then
- accept;
- reject;
- }
- filter px_metro_peer_in {
- if ebgp_in("px-metro-peer") = 1 then
- accept;
- reject;
- }
- filter px_global_backup_peer_in {
- if ebgp_in("px-global-backup-peer") = 1 then
- accept;
- reject;
- }
- filter px_metro_backup_peer_in {
- if ebgp_in("px-metro-backup-peer") = 1 then
- accept;
- reject;
- }
- filter route_server_in {
- if ebgp_in("route-server") = 1 then
- accept;
- reject;
- }
- filter global_transit_out {
- if ebgp_out("global-transit") = 1 then
- accept;
- reject;
- }
- filter metro_transit_out {
- if ebgp_out("metro-transit") = 1then
- accept;
- reject;
- }
- filter global_peer_out {
- if ebgp_out("global-peering") = 1 then
- accept;
- reject;
- }
- filter metro_peer_out {
- if ebgp_out("metro-peering") = 1 then
- accept;
- reject;
- }
- filter community_out {
- if DRAINED = 1 then
- reject;
- if net = 0.0.0.0/0 then
- accept;
- reject;
- }
- ################################################################################
- # BGP templates #
- ################################################################################
- template bgp general_bgp {
- local as AS_FFRL;
- enable route refresh on;
- graceful restart time 300;
- med metric on;
- }
- template bgp ibgp from general_bgp {
- password "%BEXL6y]";
- source address 185.66.192.3;
- import filter ibgp_in;
- }
- ##########################################
- # Upstream BGP templates #
- ##########################################
- template bgp global_transit from general_bgp {
- import filter global_transit_in;
- export filter global_transit_out;
- }
- template bgp metro_transit from general_bgp {
- import filter metro_transit_in;
- export filter metro_transit_out;
- }
- ##########################################
- # Peering BGP templates #
- ##########################################
- template bgp global_peer from general_bgp {
- import filter global_peer_in;
- export filter global_peer_out;
- }
- template bgp metro_peer from general_bgp {
- import filter metro_peer_in;
- export filter metro_peer_out;
- }
- template bgp px_global_peer from general_bgp {
- import filter px_global_peer_in;
- export filter global_peer_out;
- }
- template bgp px_metro_peer from general_bgp {
- import filter px_metro_peer_in;
- export filter metro_peer_out;
- }
- template bgp px_global_backup_peer from general_bgp {
- import filter px_global_backup_peer_in;
- export filter global_peer_out;
- }
- template bgp px_metro_backup_peer from general_bgp {
- import filter px_metro_backup_peer_in;
- export filter metro_peer_out;
- }
- template bgp route_server from general_bgp {
- import filter route_server_in;
- export filter metro_peer_out;
- }
- ##########################################
- # Downstream BGP templates #
- ##########################################
- template bgp ebgp_community from general_bgp {
- export filter {
- if net = 0.0.0.0/0 then accept;
- reject;
- };
- }
- # Load additiional configuration (iBGP, Peerings, Transits, 'n stuff)
- include "/etc/bird/bird.d/*.conf";
- include "/etc/bird/bird.d/communities/*.conf";
- include "/etc/bird/bird.d/upstreams/*.conf";
- include "/etc/bird/bird.d/peerings/*.conf";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement