1# $OpenBSD: bgpd.conf,v 1.20 2020/05/08 00:56:29 deraadt Exp $ 2# example bgpd configuration file, see bgpd.conf(5) 3 4# define our own ASN as a macro 5ASN="65001" 6 7# global configuration 8AS $ASN 9router-id 192.0.2.1 10 11# list of networks that may be originated by our ASN 12prefix-set mynetworks { 13 192.0.2.0/24 14 2001:db8:abcd::/48 15} 16 17include "/var/db/rpki-client/openbgpd" 18 19# define bogon prefixes which should not be part of the DFZ 20prefix-set bogons { 21 0.0.0.0/8 or-longer # 'this' network [RFC1122] 22 10.0.0.0/8 or-longer # private space [RFC1918] 23 100.64.0.0/10 or-longer # CGN Shared [RFC6598] 24 127.0.0.0/8 or-longer # localhost [RFC1122] 25 169.254.0.0/16 or-longer # link local [RFC3927] 26 172.16.0.0/12 or-longer # private space [RFC1918] 27 192.0.2.0/24 or-longer # TEST-NET-1 [RFC5737] 28 192.88.99.0/24 or-longer # 6to4 anycast relay [RFC7526] 29 192.168.0.0/16 or-longer # private space [RFC1918] 30 198.18.0.0/15 or-longer # benchmarking [RFC2544] 31 198.51.100.0/24 or-longer # TEST-NET-2 [RFC5737] 32 203.0.113.0/24 or-longer # TEST-NET-3 [RFC5737] 33 224.0.0.0/4 or-longer # multicast 34 240.0.0.0/4 or-longer # reserved for future use 35 ::/8 or-longer # RFC 4291 IPv4-compatible, loopback, et al 36 0100::/64 or-longer # Discard-Only [RFC6666] 37 2001:2::/48 or-longer # BMWG [RFC5180] 38 2001:10::/28 or-longer # ORCHID [RFC4843] 39 2001:db8::/32 or-longer # docu range [RFC3849] 40 2002::/16 or-longer # 6to4 anycast relay [RFC7526] 41 3ffe::/16 or-longer # old 6bone 42 fc00::/7 or-longer # unique local unicast 43 fe80::/10 or-longer # link local unicast 44 fec0::/10 or-longer # old site local unicast 45 ff00::/8 or-longer # multicast 46} 47 48# Generate routes for the networks our ASN will originate. 49# The communities (read 'tags') are later used to match on what 50# is announced to EBGP neighbors 51network prefix-set mynetworks set large-community $ASN:1:1 52 53# assume simple network with 3 routers in IBGP full mesh 54group "ibgp mesh" { 55 remote-as $ASN 56 # use loopback for IBGP sessions, assume it's distributed in OSPF 57 local-address 192.0.2.1 58 local-address 2001:db8:abcd::1 59 60 neighbor 192.0.2.2 # router 2 ipv4 61 neighbor 2001:db8:abcd::2 # router 2 ipv6 62 neighbor 192.0.2.3 # router 3 ipv4 63 neighbor 2001:db8:abcd::3 # router 3 ipv6 64} 65 66# upstream providers 67group "upstreams" { 68 neighbor 203.0.113.1 { 69 remote-as 65002 70 descr "upstream1" 71 } 72 neighbor 198.51.100.0 { 73 remote-as 65123 74 descr "upstream2-4" 75 } 76 neighbor 2001:db8:666::2 { 77 remote-as 65123 78 descr "upstream2-6" 79 } 80} 81 82## rules section 83 84# uncomment the following two lines to accept a default route from upstreams 85#allow from group upstreams prefix 0.0.0.0/0 86#allow from group upstreams prefix ::/0 87 88### for simple BGP setups, no editing below this line is required ### 89 90# Outbound EBGP: only allow self originated networks to ebgp peers 91# Don't leak any routes from upstream or peering sessions. This is done 92# by checking for routes that are tagged with the large-community $ASN:1:1 93allow to ebgp prefix-set mynetworks large-community $ASN:1:1 94 95# deny more-specifics of our own originated prefixes 96deny quick from ebgp prefix-set mynetworks or-longer 97 98# IBGP: allow all updates to and from our IBGP neighbors 99allow from ibgp 100allow to ibgp 101 102# Scrub normal and large communities relevant to our ASN from EBGP neighbors 103# https://tools.ietf.org/html/rfc7454#section-11 104match from ebgp set { community delete $ASN:* } 105match from ebgp set { large-community delete $ASN:*:* } 106 107# filter out prefixes longer than 24 or shorter than 8 bits for IPv4 108# and longer than 48 or shorter than 16 bits for IPv6. 109allow from any inet prefixlen 8 - 24 110allow from any inet6 prefixlen 16 - 48 111 112# Honor requests to gracefully shutdown BGP sessions 113# https://tools.ietf.org/html/rfc8326 114match from any community GRACEFUL_SHUTDOWN set { localpref 0 } 115 116deny quick from any prefix-set bogons 117 118# deny RPKI invalid, built by rpki-client(8), see root crontab 119deny quick from ebgp ovs invalid 120 121# filter bogon AS numbers 122# AS_TRANS (23456) is not supposed to show up in any path and indicates a 123# missconfiguration. Additionally Private or Reserved ASNs have no place in 124# the public DFZ. http://www.iana.org/assignments/as-numbers/as-numbers.xhtml 125deny quick from any AS 23456 126deny quick from any AS 64496 - 131071 127deny quick from any AS 4200000000 - 4294967295 128 129# filter out too long paths 130deny from any max-as-len 100 131