Showing posts with label BGP. Show all posts
Showing posts with label BGP. Show all posts

Saturday, February 4, 2012

Simple BGP Community Lab

This is very simple GNS3 lab for understanding BGP community. There are only two routers R1 and R2 and R1 will send two prefix 11.11.11.11/32 and 111.111.111.111/32

11.11.11.11/32 will be appear in R2 with community value 100:111 and local pref 10000 while 111.111.111.111/32 will be shown with community value 100:1212 ( default local pref 100) and metric (MED) 150.

Here is lab topology.
Download lab files from here.
Download completed files from here.



Configure R1 and R2 with following IP address and establish EBGP as below.

In R1,


interface Loopback0
 ip address 11.11.11.11 255.255.255.255
!
interface Loopback1
 ip address 111.111.111.111 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
-------------------------------

router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 neighbor 192.168.1.2 remote-as 200

--------------------------------------------------

In R2,


interface FastEthernet0/0
 ip address 192.168.1.2 255.255.255.0
-----------------

router bgp 200
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor 192.168.1.1 remote-as 100

------------------------------------------------------
Start configure bgp-community new format to allow in both routers as follow;

ip bgp-community new-format

------------------------------------
Create the following route-map in R1 to send to R2. It means access list 1 prefix will set community (100:111) and access list 2 will be set 100:1212. Add final route map permit 20 as usual.


route-map r2 permit 10
 match ip address 1
 set community 100:111
!
route-map r2 permit 15
 match ip address 2
 set community 100:1212
!
route-map r2 permit 20

------------------------------------------
Create IP access list to permit 11.11.11.11/32 and 111.111.111.111/32 as follow;


access-list 1 permit 11.11.11.11
access-list 2 permit 111.111.111.111
-------------------------------------------
Final step is to configure in BGP mode to announce these community values to R2 and announce two networks.


router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 11.11.11.11 mask 255.255.255.255
 network 111.111.111.111 mask 255.255.255.255
 neighbor 192.168.1.2 remote-as 200
 neighbor 192.168.1.2 send-community
 neighbor 192.168.1.2 route-map r2 out

-------------------------------------------------
Ok, here are the steps in R2 to capture the community values send from R1 and set different BGP attributes.

Set ip community list exactly as from R1 in configuration mode.


ip community-list 1 permit 100:111
ip community-list 2 permit 100:1212

Create route-map as follow ;


route-map fromr1 permit 10
 match community 1
 set local-preference 10000
!
route-map fromr1 permit 15
 match community 2
 set metric 150
!
route-map fromr1 permit 20
---------------------------------------------
Finally, apply these route-map to R1 in BGP configuration mode as follow;


router bgp 200
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor 192.168.1.1 remote-as 100
 neighbor 192.168.1.1 route-map fromr1 in

----------------------------------------------------------
Clear ip bgp * in one of the router before checking bgp routes.

Here is how to check the community value send from R1 in R2 as follow;


R2#sh ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  100
    192.168.1.1 from 192.168.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 10000, valid, external, best
      Community: 100:111
--------------------------------------
R2#sh ip bgp 111.111.111.111
BGP routing table entry for 111.111.111.111/32, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  100
    192.168.1.1 from 192.168.1.1 (1.1.1.1)
      Origin IGP, metric 150, localpref 100, valid, external, best
      Community: 100:1212

Saturday, February 5, 2011

BGP (using next-hop-self)

After reading BGP, I was stopped for a while how to use "next-hop-self". If you still have same problem, below simple lab will help you, I believe.

Try to reach external networks (1.1.1.1) and (2.2.2.2) injected from R1 (AS 5500) from R3. Do not announce 200.100.10.0/24 network in AS 5000.

Download full GNS3 lab from https://docs.google.com/leaf?id=0B889ogd4ltI2YTM4OGE4MGUtZDYwNi00NDE0LTkxMTItYzJlMTcwNTYyZWNl&hl=en&authkey=CPi_26EP
























R1' BGP status.

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
200.100.10.2    4  5000      10      12        3    0    0 00:06:18        0
--------
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback1
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback2
C    200.100.10.0/24 is directly connected, Serial1/0
===========================================
R2.

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.1.3     4  5000       0       0        0    0    0 never    Active
200.100.10.1    4  5500      14      12        3    0    0 00:04:12        2
-------------------
     1.0.0.0/32 is subnetted, 1 subnets
B       1.1.1.1 [20/0] via 200.100.10.1, 00:05:59
     2.0.0.0/32 is subnetted, 1 subnets
B       2.2.2.2 [20/0] via 200.100.10.1, 00:04:59
C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    200.100.10.0/24 is directly connected, Serial1/0
---------

R2#sh ip bgp
BGP table version is 3, local router ID is 200.100.10.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       200.100.10.1             0             0 5500 i
*> 2.2.2.2/32       200.100.10.1             0             0 5500 i
======================================
R3.
R3#sh ip bgp
BGP table version is 1, local router ID is 192.168.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
* i1.1.1.1/32       200.100.10.1             0    100      0 5500 i
* i2.2.2.2/32       200.100.10.1             0    100      0 5500 i
-----
There is no best route. To fix this two things need to do; one is announce the network 192.168.1.0/4 in R2 and R3 using BGP or other routing protocol.

Second, configure R2 as next hop self addresss for R3.
-----
Action in R2 as follow.
R2(config-router)#neighbor 192.168.1.3 next-hop-self

Result showing in R3 as follow.
R3#sh ip bgp
BGP table version is 1, local router ID is 192.168.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
* i1.1.1.1/32       200.100.10.1             0    100      0 5500 i
* i2.2.2.2/32       200.100.10.1             0    100      0 5500 i
R3#sh ip bgp
BGP table version is 3, local router ID is 192.168.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.1/32       192.168.1.2              0    100      0 5500 i
*>i2.2.2.2/32       192.168.1.2              0    100      0 5500 i
(Best route appear in R3) but you can't ping to 1.1.1.1. Why?
It need to announce 192.168.1.0/24 as IGBP between R2 and R3.
In R2 announce the network as follow.
R2(config)#router bgp 5000
R2(config-router)#net
R2(config-router)#network 192.168.1.0 255.255.255.0
-------------
In R3...
R3(config)#router bgp 5000
R3(config-router)#network 192.168.1.0 mask 255.255.255.0
=====================================================
Check the  BGP routing tables in R2.

R2#sh ip bgp
BGP table version is 4, local router ID is 200.100.10.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       200.100.10.1             0             0 5500 i
*> 2.2.2.2/32       200.100.10.1             0             0 5500 i
* i192.168.1.0      192.168.1.3              0    100      0 i
*>                  0.0.0.0                  0         32768 i
------------------------
In R3 BGP routing table.
R3#sh ip bgp
BGP table version is 6, local router ID is 192.168.1.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.1/32       192.168.1.2              0    100      0 5500 i
*>i2.2.2.2/32       192.168.1.2              0    100      0 5500 i
*> 192.168.1.0      0.0.0.0                  0         32768 i
* i                 192.168.1.2              0    100      0
-----------
Best route and (i) internal route will appear and BGP will know how to route to two external routers (1.1.1.1) and (2.2.2.2)
Testing by pining.
-----
R3#ping 2.2.2.2


Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/16/28 ms


R3#traceroute 2.2.2.2


Type escape sequence to abort.
Tracing the route to 2.2.2.2


  1 192.168.1.2 16 msec 20 msec 8 msec
  2 200.100.10.1 12 msec 8 msec *
===========================================
Using this topology will achive both IBGP and EBGP, how to use next-hop-self and external routes (200.100.10.0/24) is not needed to announce in internal network.