#log syslog all; log "/var/log/bird/bird.log" all; #debug protocols all; #debug ospf_area0 { states, routes }; router id 195.x.y.z1; protocol device { scan time 10; } protocol kernel { learn; # persist; export all; import all; scan time 15; } protocol static STATIC_BGP { route net1/24 drop; route net2/24 drop; route net3/24 drop; } protocol static STATIC_OSPF { route 10.0.0.0/8 drop; route 172.16.0.0/12 drop; route 192.168.0.0/16 drop; } protocol direct { interface "*"; } protocol ospf ospf_area0 { #debug { states, events, packets }; debug { states, events }; #import all; import filter { if ( net != 0.0.0.0/0 ) then { print "OSPF accepted: ", net; accept; } print "OSFP rejected:", net; reject; }; export filter { ospf_metric2 = 20; if net = 0.0.0.0/0 then reject; # connected if source = RTS_DEVICE then accept; #if source = RTS_STATIC then accept; if proto = "STATIC_OSPF" then accept; #if proto = "STATIC_BGP" then accept; # connected loopback ? if source = RTS_STATIC_DEVICE then accept; # kernel route if source = RTS_INHERIT then accept; # ospf route if source = RTS_OSPF then accept; else reject; }; area 0.0.0.0 { interface "eth0.1889" net4/29 { cost 40; type broadcast; hello 1; dead 4; }; interface "eth1.2508" net5/30 { cost 40; type broadcast; hello 1; dead 10; }; interface "greegw*" { cost 500; type pointopoint; hello 1; dead 4; }; }; } function net_martian() { return net ~ [ 169.254.0.0/16+, 172.16.0.0/12+, 192.168.0.0/16+, 10.0.0.0/8+, 127.0.0.0/8+, 224.0.0.0/4+, 240.0.0.0/4+, 0.0.0.0/32-, 0.0.0.0/0{25,32}, 0.0.0.0/0{0,7}, 100.64.0.0/10+, 192.0.2.0/24+, 198.18.0.0/15+, 198.51.100.0/24+ ]; } function net_local() { return net ~ [ net1/23{23,24}, net2/24, net3/23{23,24} ]; } template bgp IBGP { #debug all; local as MYAS; next hop self; deterministic med on; med metric on; source address 195.x.y.z1; password "gfhjkmlkzbgp"; import all; export filter { # advertise our net if proto = "STATIC_BGP" then { print "STATIC_BGP accepted: ", net; accept; } # advertise eBGP if source = RTS_BGP then accept; else reject; }; } protocol bgp bgp_egw2 from IBGP { neighbor 195.x.y.z2 as MYAS; } protocol bgp bgp_egw4 from IBGP { neighbor 195.x.y.z4 as MYAS; } filter f_megacom_in { # deny IN net_martian and net_local if ( net_martian() || net_local() ) then reject; # deny as path > 64 if bgp_path.len > 64 then reject; accept; } filter f_megacom_out { # advertise net_local if ( net_local() ) then { bgp_path.prepend(MYAS); bgp_path.prepend(MYAS); accept; } reject; } protocol bgp bgp_megacom { local as MYAS; neighbor 194.x.y.z as 44587; description "Megacom"; default bgp_local_pref 100; deterministic med on; med metric on; export filter f_megacom_out; import filter f_megacom_in; # bfd on; filter f_avantel_in { if ( net_martian() || net_local() ) then reject; if bgp_path.len > 64 then reject; if ( bgp_path ~ [= 25549 3216 * =] ) then { bgp_local_pref = 50; accept; } if ( bgp_path ~ [= * 43154 * =] || bgp_path ~ [= * 42304 =] ) then { bgp_local_pref = 300; accept; } if ( bgp_path ~ [= * 64530 * =] || bgp_path ~ [= * 39785 * =] ) then reject; if ( bgp_path ~ [= 25549 20485 * =] ) then { bgp_local_pref = 50; accept; } if ( bgp_path ~ [= 25549 9002 * =] ) then { bgp_path.delete(25549); accept; } accept; } filter f_avantel_out { # advertise net_local if ( net_local() ) then { # KRS-IX community 0:49039 13002:4130 64512:51220 64512:51240 64512:51370 64512:51380 64512:51470 64512:51480 bgp_community.add ((0,49039)); bgp_community.add ((13002,4130)); bgp_community.add ((64512,51220)); bgp_community.add ((64512,51240)); bgp_community.add ((64512,51370)); bgp_community.add ((64512,51380)); bgp_community.add ((64512,51470)); bgp_community.add ((64512,51480)); bgp_path.prepend(MYAS); bgp_path.prepend(MYAS); bgp_path.prepend(MYAS); accept; } reject; } protocol bgp bgp_avantel { local as MYAS; neighbor 195.x.y.z as 25549; default bgp_local_pref 100; deterministic med on; med metric on; export filter f_avantel_out; import filter f_avantel_in; }