FullBGP at Home

Page content

did you always wanted to have a fullbgp table at home once ? Over your DSL / CM / LTE or whatever connection ? here a little howto :)

Setup VM

Install a VM with OpenBSD. Add 1 CPU, 1 GB RAM, 20 GB Disk, nothing special

Check our Upstream Provider

Check the Page from Lukasz and spend him a Beer if you ever meet him.

Edit your Config

set the router-id to your Public IP. This Value must be uniqe, so your PubIP is perfect for that.

cat <<'EOF'> /etc/bgpd.conf
# define our own ASN as a macro
ASN="65001"

# global configuration
AS $ASN
router-id YOUR-PUBLIC-IP-ADDRESS

# list of networks that may be originated by our ASN
prefix-set mynetworks {
}

# as our Servers are distributed throught the Internet and not directly Connected, this line is important !
nexthop qualify via default

# udpate fib ?
fib-update yes

# hold time
holdtime 7200

# define bogon prefixes which should not be part of the DFZ
prefix-set bogons {
	0.0.0.0/8 or-longer		# 'this' network [RFC1122]
	10.0.0.0/8 or-longer		# private space [RFC1918]
	100.64.0.0/10 or-longer		# CGN Shared [RFC6598]
	127.0.0.0/8 or-longer		# localhost [RFC1122]
	169.254.0.0/16 or-longer	# link local [RFC3927]
	172.16.0.0/12 or-longer		# private space [RFC1918]
	192.0.2.0/24 or-longer		# TEST-NET-1 [RFC5737]
	192.88.99.0/24 or-longer	# 6to4 anycast relay [RFC7526]
	192.168.0.0/16 or-longer	# private space [RFC1918]
	198.18.0.0/15 or-longer		# benchmarking [RFC2544]
	198.51.100.0/24 or-longer	# TEST-NET-2 [RFC5737]
	203.0.113.0/24 or-longer	# TEST-NET-3 [RFC5737]
	224.0.0.0/4 or-longer		# multicast
	240.0.0.0/4 or-longer		# reserved for future use
	::/8 or-longer			# RFC 4291 IPv4-compatible, loopback, et al
	0100::/64 or-longer		# Discard-Only [RFC6666]
	2001:2::/48 or-longer		# BMWG [RFC5180]
	2001:10::/28 or-longer		# ORCHID [RFC4843]
	2001:db8::/32 or-longer		# docu range [RFC3849]
	2002::/16 or-longer		# 6to4 anycast relay [RFC7526]
	3ffe::/16 or-longer		# old 6bone
	fc00::/7 or-longer		# unique local unicast
	fe80::/10 or-longer		# link local unicast
	fec0::/10 or-longer		# old site local unicast
	ff00::/8 or-longer		# multicast
}

# upstream providers
group "upstreams" {
	neighbor 94.246.173.181 {
		remote-as 65000
		descr "lukasz.bromirski.net"
    multihop 15
	}
}

## 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 or-longer

# 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 }

deny quick from any prefix-set bogons

# filter bogon AS numbers
# AS_TRANS (23456) is not supposed to show up in any path and indicates a
# missconfiguration. Additionally Private or Reserved ASNs have no place in
# the public DFZ. http://www.iana.org/assignments/as-numbers/as-numbers.xhtml
deny quick from any AS 23456
deny quick from any AS 64496 - 64499
deny quick from any AS 4200000000 - 4294967295

# filter out too long paths
deny from any max-as-len 100
EOF

Start the Daemon

chmod 600 /etc/bgpd.conf
rcctl enable bgpd
rcctl start bpgd

Check BGP Session

root@play43 ~# bgpctl show                                                                                                                                             
Neighbor                   AS    MsgRcvd    MsgSent  OutQ Up/Down  State/PrfRcvd
lukasz.bromirski.net    65000     128772          2     0 00:18:16 823509

Enjoy the Table

root@play43 ~# bgpctl show ip bgp in |head         
flags: * = Valid, > = Selected, I = via IBGP, A = Announced,
       S = Stale, E = Error
origin validation state: N = not-found, V = valid, ! = invalid
origin: i = IGP, e = EGP, ? = Incomplete

flags ovs destination          gateway          lpref   med aspath origin
*       N 1.0.0.0/24           94.246.173.181    100     0 65000 65055 43372 13335 i
*       N 1.0.4.0/22           94.246.173.181    100     0 65000 65055 43372 6939 4826 38803 56203 i
*       N 1.0.4.0/24           94.246.173.181    100     0 65000 65055 43372 6939 4826 38803 56203 i
*       N 1.0.5.0/24           94.246.173.181    100     0 65000 65055 43372 6939 4826 38803 56203 i

or

root@play43 ~# route -n show -inet |head 
Routing tables

Internet:
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            192.168.108.1      UGS        8       50     -     8 em0  
224/4              127.0.0.1          URS        0      392 32768     8 lo0  
1.128/11           192.168.108.1      UG         0        0     -    48 em0  
1.224/11           192.168.108.1      UG         0        0     -    48 em0  
1.0.128/17         192.168.108.1      UG         0        0     -    48 em0  
1.0.128/18         192.168.108.1      UG         0        0     -    48 em0  

or

root@play43 ~# route -n show -inet |wc -l
  819408

so, if you don’t know what’s this all about, i’m certain you don’t need a full table and you’ll be happy with a default route :)

sha256: 0166f424d21e65973219385ee9e4ef7f4fd77119fbe65bdcf8f7e578824acd06