BGP configuration example - BIRD

Please change the data to your own

# 185.37.8.1 - client's router ipv4 address
# 185.37.8.0/24 - client's ipv4 net
# 2a10:c947::/32 - client's ipv6 net
# 206447 - client's ASn 
# 5.101.92.180 - client's ipv4 address in LL-IX
# 2001:678:4fc::92:180 - client's ipv4 address in LL-IX


Configuration example:

log syslog all;
router id 185.37.8.1;

protocol device { }
protocol direct { ipv4; ipv6; }
protocol kernel { ipv4 { export all; }; }
protocol kernel { ipv6 { export all; }; }
protocol static { ipv4; route 185.37.8.0/24  unreachable; }
protocol static { ipv6; route 2a10:c947::/32 unreachable; }

function is_default()    { return net ~ [ 0.0.0.0/0 ]; }
function is_default_v6() { return net ~ [ ::/0      ]; }

function is_martian(){
  return net ~ [ 169.254.0.0/16+, 172.16.0.0/12+, 192.168.0.0/16+, 10.0.0.0/8+, 224.0.0.0/4+, 240.0.0.0/4+, 193.254.225.0/24];
}

function is_martian_v6(){
  return net ~ [ ::/96, ::/128, ::1/128, ::ffff:0.0.0.0/96+, ::224.0.0.0/100+, ::127.0.0.0/104+,                                     
                 ::0.0.0.0/104+, ::255.0.0.0/104+, 0000::/8+, 0200::/7+, 3ffe::/16+, 2001:db8::/32+,
                 2002:e000::/20+, 2002:7f00::/24+, 2002:0000::/24+, 2002:ff00::/24+, 2002:0a00::/24+,
                 2002:ac10::/28+, 2002:c0a8::/32+, fc00::/7+, fe80::/10+, fec0::/10+, ff00::/8+ ];
}

function is_self_net()    { return net ~ [ 185.37.8.0/24  ]; }
function is_self_net_v6() { return net ~ [ 2a10:c947::/32 ]; }
function is_my_asn()      { return bgp_path.last ~ [ 206447 ]; }

filter import_AS59947_v4
{
  if is_martian()  then reject;
  if is_my_asn()   then reject;
  if is_self_net() then reject;
  if is_default()  then reject;
  bgp_local_pref   = 150;
  krt_prefsrc      = 185.37.8.1;
  accept;
}

filter import_AS59947_v6
{
  if is_martian_v6()  then reject;
  if is_my_asn()      then reject;
  if is_self_net_v6() then reject;
  if is_default_v6()  then reject;
  bgp_local_pref      = 150;
  bgp_next_hop        = bgp_next_hop;  
  accept;
}

filter export_AS59947_v4
{
  if is_martian()  then reject;
  if is_default()  then reject;
  if is_self_net() then accept;
  reject;
}

filter export_AS59947_v6
{
  if is_martian_v6()  then reject;
  if is_default_v6()  then reject;
  if is_self_net_v6() then accept;
  reject;
}

protocol bgp RS1_LL_IX_v4 {
  local as           206447;
  connect delay time 40;
  neighbor           5.101.92.9 as 59947;
  source address     5.101.92.180;
  ipv4 {
    next hop self;
    export filter export_AS59947_v4;
    import filter import_AS59947_v4;
  };
}

protocol bgp RS2_LL_IX_v4 {
  local as           206447;
  connect delay time 40;
  neighbor           5.101.92.2 as 59947;
  source address     5.101.92.180;
  ipv4 {
    next hop self;
    export filter export_AS59947_v4;
    import filter import_AS59947_v4;
  };
}

protocol bgp RS1_LL_IX_v6 {
  local as       206447;
  neighbor       2001:678:4fc::9 as 59947;
  source address 2001:678:4fc::92:180;
  ipv6 {
    next hop address  2001:678:4fc::92:180;
    export filter     export_AS59947_v6;
    import filter     import_AS59947_v6;
  };
}

protocol bgp RS2_LL_IX_v6 {
  local as       206447;
  neighbor       2001:678:4fc::2 as 59947;
  source address 2001:678:4fc::92:180;
  ipv6 {
    next hop address  2001:678:4fc::92:180;
    export filter     export_AS59947_v6;
    import filter     import_AS59947_v6;
  };
}
  • BIRD, BGP
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

BGP configuration example - RouterOS Mikrotik

Please change the data to your own: 185.37.8.1 - client's router ipv4 address 185.37.8.0/24 -...

BGP configuration example - Cisco

Please change the data to your own XXXX - your ASN number 192.168.0/24 and 192.168.1/24 - your...

BGP configuration example - Juniper

Please change the data to your own XXXX - your ASN number 192.168.0/24 and 192.168.1/24 - your...