summaryrefslogtreecommitdiff
path: root/etc/examples/bgpd.conf
blob: d0765d1b6424b7a6bd243a2aca47c84ae4118aee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# $OpenBSD: bgpd.conf,v 1.11 2018/08/28 17:52:16 job Exp $
# example bgpd configuration file, see bgpd.conf(5)

# define our own ASN as a macro
ASN="65001"

# global configuration
AS $ASN
router-id 192.0.2.1

# Generate routes for the networks our ASN will originate.
# The communities (read 'tags') are later used to match on what
# is announced to EBGP neighbors
network 192.0.2.0/24 set large-community $ASN:1:1
network 2001:db8:abcd::/48 set large-community $ASN:1:1

# list of networks that may be originated by our ASN
prefix-set mynetworks {		\
	192.0.2.0/24		\
	2001:db8:abcd::/48	\
}

# this prefix-set is used to protect against accepting
# hijacks of our own originated address space
prefix-set mynetworks_orlonger {	\
	192.0.2.0/24 or-longer		\
	2001:db8:abcd::/48 or-longer	\
}

# assume simple network with 3 routers in IBGP full mesh
group "ibgp mesh v4" {
	remote-as $ASN
	# use loopback for IBGP sessions, assume its distributed in OSPF
	local-address 192.0.2.1
	neighbor 192.0.2.2		# router 2 ipv4
	neighbor 192.0.2.3		# router 3 ipv4
}
# define the IPv6 IBGP sessions
group "ibgp mesh v6" {
	remote-as $ASN
	local-address 2001:db8:abcd::1
	neighbor 2001:db8:abcd::2	# router 2 ipv6
	neighbor 2001:db8:abcd::3	# router 3 ipv6
}

# upstream providers
group "upstreams" {
	neighbor 203.0.113.1 {
		remote-as 65002
		descr "IPv4 Transit Provider A"
	}
	neighbor 198.51.100.0 {
		remote-as 65123
		descr "IPv4 Transit provider B"
	}
	neighbor 2001:db8:666::2 {
		remote-as 65123
		descr "IPv6 Transit provider B"
	}
}

## rules section

# uncomment the following two lines to accept a default route from upstreams
#allow from group upstreams prefix 0.0.0.0/0
#allow from group upstreams prefix ::/0

### for simple BGP setups, no editing below this line is required ###

# Outbound EBGP: only allow self originated networks to ebgp peers
# Don't leak any routes from upstream or peering sessions. This is done
# by checking for routes that are tagged with the large-community $ASN:1:1
allow to ebgp prefix-set mynetworks large-community $ASN:1:1

# deny more-specifics of our own originated prefixes
deny quick from ebgp prefix-set mynetworks_orlonger

# IBGP: allow all updates to and from our IBGP neighbors
allow from ibgp
allow to ibgp

# Scrub normal and large communities relevant to our ASN from EBGP neighbors
# https://tools.ietf.org/html/rfc7454#section-11
match from ebgp set { community delete $ASN:* }
match from ebgp set { large-community delete $ASN:*:* }

# filter out prefixes longer than 24 or shorter than 8 bits for IPv4
# and longer than 48 or shorter than 16 bits for IPv6.
allow from any inet prefixlen 8 - 24
allow from any inet6 prefixlen 16 - 48

# Honor requests to gracefully shutdown BGP sessions
# https://tools.ietf.org/html/rfc8326
match from any community GRACEFUL_SHUTDOWN set { localpref 0 }

# See http://bgpfilterguide.nlnog.net/guides/bogon_prefixes/ for
# an elaboration why each prefix is a bogon
prefix-set bogons {						\
	0.0.0.0/8 or-longer, 10.0.0.0/8 or-longer,		\
	100.64.0.0/10 or-longer, 127.0.0.0/8 or-longer,		\
	169.254.0.0/16 or-longer, 172.16.0.0/12 or-longer, 	\
	192.0.2.0/24 or-longer, 192.88.99.0/24 or-longer,	\
	192.168.0.0/16 or-longer, 198.18.0.0/15 or-longer,	\
	198.51.100.0/24 or-longer, 203.0.113.0/24 or-longer,	\
	224.0.0.0/4 or-longer, 240.0.0.0/4 or-longer,		\
	::/8 or-longer, 0100::/64 or-longer,			\
	2001:2::/48 or-longer, 2001:10::/28 or-longer,		\
	2001:db8::/32 or-longer, 2002::/16 or-longer,		\
	3ffe::/16 or-longer, fc00::/7 or-longer,		\
	fe80::/10 or-longer, fec0::/10 or-longer,		\
	ff00::/8 or-longer					\
}
# use above prefix-set to reject the bogons
deny quick from any prefix-set bogons

# filter bogon AS numbers
# see http://bgpfilterguide.nlnog.net/guides/bogon_asns/ for more
# information why these ASNs are bogons.
deny quick from any AS 23456
deny quick from any AS 64496 - 131071
deny quick from any AS 4200000000 - 4294967295