log "/var/log/bgp.log" all; router id 1.0.0.1; function net_martian() { return net ~ [ 0.0.0.0/8, 10.0.0.0/8+, 100.64.0.0/10+, 127.0.0.0/8+, 169.254.0.0/16+, 172.16.0.0/12+, 192.0.0.0/24+, 192.0.2.0/24+, 192.168.0.0/16+, 198.18.0.0/15+, 198.51.100.0/24+, 203.0.113.0/24+, 224.0.0.0/3+ ]; } function net_local_bgp() { return net ~ [ 1.0.0.0/20 ]; } function rt_import_ebgp() { if net_martian() || net_local_bgp() then return false; if bgp_path.len > 64 then return false; return true; } function rt_export_ebgp() { if net_martian() then return false; if bgp_path.len > 64 then return false; return true; } filter upstream_in { if ( rt_import_ebgp() ) then { bgp_local_pref=600; accept; } else { reject; } } filter upstream_out { if ( rt_export_ebgp() ) && ( net_local_bgp() ) then { accept; } else { reject; } } protocol kernel { scan time 60; # Scan kernel routing table every 60 seconds import all; # Default is import all export all; # Default is export none } protocol device { scan time 20; } protocol static static_bgp { preference 1200; route 1.0.0.0/20 drop; } template bgp PEERS { debug {events, states}; local as 65001; hold time 180; startup hold time 90; connect retry time 30; keepalive time 30; start delay time 5; error wait time 60, 300; error forget time 300; gateway direct; path metric 1; default bgp_med 0; default bgp_local_pref 100; } protocol bgp test from PEERS { neighbor 172.17.1.241 as 65000; import filter upstream_in; export filter upstream_out; }