niab bgp tutorial lab

Lab diagram

bgp lab diagram

Lab aim

This is the third of five labs that make up the niab tutorial.  To complete
the tutorial, it is recommended that you follow the lab-guides in this order.
demo-lab-guide: Introduction to using niab.
ospf-lab-guide: OSPF tutorial.
bgp-lab-guide: BGP tutorial.                             << You are here !
ent1-lab-guide: DNS, email, web tutorial.
isp1-lab-guide: Use external lab connections.

Covers the configuration and support of the BGP routing protocol.

Lab overview

View the lab diagram 'bgp.png' supplied with this lab.

9 routers form a multiple ISP BGP network.
isp1 [AS65001] consists of routers isp1r01, isp1r02, isp1r03, isp1r04.
isp2 [AS65002] consists of routers isp2r01, isp2r02, isp2r03, isp2r04.
isp3 [AS65003] consists of router isp3r01.

IBGP (Internal BGP)
IBGP is configured on all routers in isp1 and isp2.  isp1r02 and isp2r02 are
configured as BGP RR's (Route Reflectors) and each RR, peers with every
other router within the AS.
This results in the following 6 IBGP peerings within the network:
1) isp1r02-dummy0 (RR) <-- IBGP --> isp1r01-dummy0
2) isp1r02-dummy0 (RR) <-- IBGP --> isp1r03-dummy0
3) isp1r02-dummy0 (RR) <-- IBGP --> isp1r04-dummy0
4) isp2r02-dummy0 (RR) <-- IBGP --> isp2r01-dummy0
5) isp2r02-dummy0 (RR) <-- IBGP --> isp2r03-dummy0
6) isp2r02-dummy0 (RR) <-- IBGP --> isp2r04-dummy0
[IBGP peerings are initiated and terminate on each routers dummy0 interface.]

EBGP (External BGP)
There are 4 EBGP peerings within the network:
1) isp1r03-eth0 <-- EBGP --> isp2r03-eth0
2) isp1r04-eth0 <-- EBGP --> isp2r04-eth0
3) isp1r01-eth1 <-- EBGP --> isp3r01-eth0
4) isp2r01-eth1 <-- EBGP --> isp3r01-eth1
[EBGP peerings are initiated and terminate on the interface connecting to the
neighbour.]

The dummy0 virtual interface IP address is also used as the BGP router-id.

Lab instructions

1) Restore the lab
We perform the same steps as described in the 'demo' tutorial.

- start the lab
[ncarter:~/niab-labs/bgp]>niab start
[ncarter:~/niab-labs/bgp]>

- wait for nodes to boot (tail log/*.log file to view boot progress)

- restore the lab configuration
Only attempt this once all the nodes are fully booted.
[ncarter:~/niab-labs/bgp]>niab restore
niab: node 'isp1r01' config restored from ./node-configs/isp1r01
niab: node 'isp1r02' config restored from ./node-configs/isp1r02
niab: node 'isp1r03' config restored from ./node-configs/isp1r03
niab: node 'isp1r04' config restored from ./node-configs/isp1r04
niab: node 'isp2r01' config restored from ./node-configs/isp2r01
niab: node 'isp2r02' config restored from ./node-configs/isp2r02
niab: node 'isp2r03' config restored from ./node-configs/isp2r03
niab: node 'isp2r04' config restored from ./node-configs/isp2r04
niab: node 'isp3r01' config restored from ./node-configs/isp3r01
[ncarter:~/niab-labs/bgp]>

- stop the lab
[ncarter:~/niab-labs/bgp]>niab stop
[ncarter:~/niab-labs/bgp]>

- wait for nodes to stop

- start the lab
Only attempt this once all nodes have stopped.
[ncarter:~/niab-labs/bgp]>niab start
[ncarter:~/niab-labs/bgp]>

- wait for nodes to boot (tail log/*.log file to view boot progress)

2) Connect to node isp1r01, and log in as user root.
If you are running X-Windows:
[ncarter:~/niab-labs/bgp]>niab term isp1r01
[ncarter:~/niab-labs/bgp]>
An xterm connected to isp1r01, displaying a login prompt, will appear.

If you are not running X-Windows:
- use 'niab nodes' command to find out which tcp port is bound to isp1r01
- telnet to the tcp port


3) Check connectivity
All routers in this lab should be able to ping each other.
- ping each remote router

isp1r01:~# ping -c 2 isp1r02
PING isp1r02 (10.128.32.2): 56 data bytes
64 bytes from 10.128.32.2: icmp_seq=0 ttl=64 time=36.6 ms
64 bytes from 10.128.32.2: icmp_seq=1 ttl=64 time=1.9 ms

--- isp1r02 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 1.9/19.2/36.6 ms
isp1r01:~#

Repeat for the other 7 remote routers.

If any of these pings fail then its time to start troubleshooting.

4) View isp1r01 BGP configuration
isp1r01:~# telnet localhost bgpd
...
Escape character is '^]'.
...
User Access Verification
Password: zebra
isp1r01-bgpd> enable
Password: zebra
isp1r01-bgpd# sh run
...
router bgp 65001  << isp1 AS number
 bgp router-id 10.128.32.1                 << router-id is dummy0 address
 network 10.128.32.0/22                    << Advertise summary route for isp1
 neighbor 10.128.32.2 remote-as 65001      << IBGP peer to isp1r02
 neighbor 10.128.32.2 update-source dummy0 << IBGP peer source address dummy0
 neighbor 10.128.33.50 remote-as 65003     << EBGP peer to isp3r01
...


5) View isp1r01 BGP neighbours
isp1r01-bgpd# sh ip bgp summary
BGP router identifier 10.128.32.1, local AS number 65001
4 BGP AS-PATH entries
0 BGP community entries

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down
 State/PfxRcd
10.128.32.2     4 65001    2809    2813        0    0    0 1d22h46m        1
10.128.33.50    4 65003    2809    2815        0    0    0 1d22h48m        2

Total number of neighbors 2
isp1r01-bgpd#

6) View isp1r01 BGP Keepalives

isp1r01-bgpd# term monitor
isp1r01-bgpd# debug bgp keepalives
BGP keepalives debugging is on
isp1r01-bgpd#
2004/06/18 15:16:26 BGP: 10.128.32.2 sending KEEPALIVE  << 1)
2004/06/18 15:16:26 BGP: 10.128.33.50 sending KEEPALIVE << 2)
2004/06/18 15:16:26 BGP: 10.128.32.2 KEEPALIVE rcvd
2004/06/18 15:16:56 BGP: 10.128.33.50 KEEPALIVE rcvd
2004/06/18 15:17:26 BGP: 10.128.32.2 sending KEEPALIVE  << 1) IBGP 60s gap
2004/06/18 15:17:26 BGP: 10.128.33.50 sending KEEPALIVE << 2) EBGP 60S gap

isp1r01-bgpd# no deb bgp keepalives
BGP keepalives debugging is off
isp1r01-bgpd#


7) View isp1r01 BGP Table
isp1r01-bgpd# sh ip bgp
BGP table version is 0, local router ID is 10.128.32.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop  Metric LocPrf Weight Path
*> 10.128.32.0/22   0.0.0.0                  32768 i           << Own isp(isp1)
*>i10.128.36.0/22   10.128.33.34        100      0 65002 i     << isp2 direct
*                   10.128.33.50                 0 65003 65002 << isp2 via isp3
i *> 10.128.40.0/22   10.128.33.50               0 65003 i     << isp3 direct


9) View isp1r01 zebra bgp routes
isp1r01-bgpd# exit
Connection closed by foreign host.
isp1r01:~# telnet localhost zebra
Password: zebra
isp1r01-zebra> sh ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       B - BGP, > - selected route, * - FIB route

B>* 10.128.36.0/22 [200/0] via 10.128.33.34 (recursive via 10.128.33.2),
 08:49:45
    ^^^^^^^^^^^^^^  ^^^        ^^^^^^^^^^^^                ^^^^^^^^^^^
    isp2 summary   IBGP        BGP Next Hop                (IGP) Next Hop

B>* 10.128.40.0/22 [20/0] via 10.128.33.50, eth1, 1d23h03m
    ^^^^^^^^^^^^^^  ^^^       ^^^^^^^^^^^^
    isp3 summary   EBGP       BGP/IGP Next Hop


10) View isp1r01 BGP originated kernel routes
isp1r01-zebra> exit
Connection closed by foreign host.

isp1r01:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
...
10.128.36.0     10.128.33.2     255.255.252.0   UG        0 0          0 eth0
^^^^^^^^^^^     ^^^^^^^^^^^     ^^^^^^^^^^^^^
isp2            (IGP) Next Hop  Summary

10.128.40.0     10.128.33.50    255.255.252.0   UG        0 0          0 eth1
^^^^^^^^^^^     ^^^^^^^^^^^^    ^^^^^^^^^^^^^
isp3            (IGP) Next Hop  Summary


11) Check BGP reconverges after link failure
- shutdown isp1eth1
[Use zebra to shutdown the 'zebra' interface, do not use the 'ifconfig' command
to shutdown the 'kernel' interface.  Other processes are using the 'kernel'
interface, so the 'ifconfig' command will fail.]
isp1r01:~# telnet localhost zebra
Password: zebra
isp1r01-zebra> en
Password: zebra
isp1r01-zebra# conf t
isp1r01-zebra(config)# int eth1
isp1r01-zebra(config-if)# shutdown
isp1r01-zebra(config-if)# end
isp1r01-zebra#


- check alternate route has been found
isp1r01-zebra# sh ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       B - BGP, > - selected route, * - FIB route

B>* 10.128.36.0/22[200/0] via 10.128.33.34(recursive via 10.128.33.2),09:03:50
                                                                      ^^^^^^^^
                                                       Route to isp2 unchanged
B>* 10.128.40.0/22[200/0] via 10.128.33.34(recursive via 10.128.33.2),00:00:23
                              ^^^^^^^^^^^^                            ^^^^^^^^
                              Route to isp3 changed, now via isp2

12) Have a play !  If you completely break the lab, you can easily restore the
original setting using the 'niab restore' command on the host system.

13) Stop the lab
[ncarter:~/niab-labs/bgp]>niab stop
[ncarter:~/niab-labs/bgp]>

14) Move on to the next tutorial lab (ent1)


Appendix 1: IP Subnetting (bgp tutorial lab)

10.128.32.0/20 - Lab Summary
  10.128.32.0/24 - 256 x /32 isp1 dummy0
  10.128.33.0/24 - 32 x /29 isp1 LAN links
  10.128.34.0/24 - 64 x /30 isp1 WAN links
  10.128.35.0/24 - isp1 unassigned
  10.128.36.0/24 - 256 x /32 isp2 dummy0
  10.128.37.0/24 - 32 x /29 isp2 LAN links
  10.128.38.0/24 - 64 x /30 isp2 WAN links
  10.128.39.0/24 - isp2 unassigned
  10.128.40.0/24 - 256 x /32 isp3 dummy0
  10.128.41.0/24 - 32 x /29 isp3 LAN links
  10.128.42.0/24 - 64 x /30 isp3 WAN links
  10.128.43.0/24 - isp3 unassigned
  10.128.44.0/24 - 10.128.47.0/24 unassigned