Made possible by PowerDNS | ||
---|---|---|
Prev | Chapter 17. Dynamic routing - OSPF and BGP | Next |
The Border Gateway Protocol Version 4 (BGP4) is a dynamic routing protocol described in RFC 1771. It allows the distribution of reachability information, i.e. routing tables, to other BGP4 enabled nodes. It can either be used as EGP or IGP, in EGP mode each node must have its own Autonomous System (AS) number. BGP4 supports Classless Inter Domain Routing (CIDR) and route aggregation (merge multiple routes into one).
The following network map is used for further examples. AS 1 and 50 have more neighbors but we only need to configure 1 and 50 as our neighbor. The nodes itself communicate over tunnels in this example but that is not a must.
Note: The AS numbers used in this example are reserved, please get your own AS from RIPE if you set up official peerings.
-------------------- | 192.168.23.12/24 | | AS: 23 | -------------------- / \ / \ / \ ------------------ ------------------ | 192.168.1.1/24 |-------| 10.10.1.1/16 | | AS: 1 | | AS: 50 | ------------------ ------------------
The following configuration is written for node 192.168.23.12/24, it is easy to adapt it for the other nodes.
It starts with some general stuff like hostname, passwords and debug switches:
! hostname hostname anakin ! login password password xxx ! enable password (super user mode) enable password xxx ! path to logfile log file /var/log/zebra/bgpd.log ! debugging: be verbose (can be removed afterwards) debug bgp events debug bgp filters debug bgp fsm debug bgp keepalives debug bgp updates
Access list, used to limit the redistribution to private networks (RFC 1918).
! RFC 1918 networks access-list local_nets permit 192.168.0.0/16 access-list local_nets permit 172.16.0.0/12 access-list local_nets permit 10.0.0.0/8 access-list local_nets deny any
Next step is to do the per AS configuration:
! Own AS number router bgp 23 ! IP address of the router bgp router-id 192.168.23.12 ! announce our own network to other neighbors network 192.168.23.0/24 ! advertise all connected routes (= directly attached interfaces) redistribute connected ! advertise kernel routes (= manually inserted routes) redistribute kernel
Every 'router bgp' block contains a list of neighbors to which the router is connected to:
neighbor 192.168.1.1 remote-as 1 neighbor 192.168.1.1 distribute-list local_nets in neighbor 10.10.1.1 remote-as 50 neighbor 10.10.1.1 distribute-list local_nets in
Note: vtysh is a multiplexer and connects all the Zebra interfaces together.
anakin# sh ip bgp summary BGP router identifier 192.168.23.12, local AS number 23 2 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.10.0.1 4 50 35 40 0 0 0 00:28:40 1 192.168.1.1 4 1 27574 27644 0 0 0 03:26:04 14 Total number of neighbors 2 anakin# anakin# sh ip bgp neighbors 10.10.0.1 BGP neighbor is 10.10.0.1, remote AS 50, local AS 23, external link BGP version 4, remote router ID 10.10.0.1 BGP state = Established, up for 00:29:01 .... anakin#
Let's see which routes we got from our neighbors:
anakin# sh ip ro bgp Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, B - BGP, > - selected route, * - FIB route B>* 172.16.0.0/14 [20/0] via 192.168.1.1, tun0, 2d10h19m B>* 172.30.0.0/16 [20/0] via 192.168.1.1, tun0, 10:09:24 B>* 192.168.5.10/32 [20/0] via 192.168.1.1, tun0, 2d10h27m B>* 192.168.5.26/32 [20/0] via 192.168.1.1, tun0, 10:09:24 B>* 192.168.5.36/32 [20/0] via 192.168.1.1, tun0, 2d10h19m B>* 192.168.17.0/24 [20/0] via 192.168.1.1, tun0, 3d05h07m B>* 192.168.17.1/32 [20/0] via 192.168.1.1, tun0, 3d05h07m B>* 192.168.32.0/24 [20/0] via 192.168.1.1, tun0, 2d10h27m anakin#