Create numerous BGP sources with a single router

From CT3

Jump to: navigation, search

By Ivan Pepelnjak

The multi-VRF feature available in Cisco IOS enables creation of multiple independent routing contexts in a single router that is not participating in an MPLS VPN backbone. This feature can also be used in lab environments to generate numerous external route sources on a single physical router.

It’s easy to generate virtual OSPF or EIGRP routers, as you can start multiple OSPF processes on a router and configure an independent EIGRP AS number for each VRF. Generating multiple BGP sources using different AS numbers was impossible until Cisco added the replace-as keyword to the neighbor local-as router configuration command. The neighbor local-as command allows a router to masquerade its AS-number, but the actual AS number remains in the AS-path. The replace-as keyword hides the actual AS number used by the router’s BGP process, leaving only the local-AS in the AS-path.

For example, a single router connected to one or more lab routers through VLAN interfaces can emulate multiple ISP customers (see the router configurations at the bottom of the article).

Image:BGPEmulation.png

The show ip bgp summary command executed on the Lab router displays three neighbors in different AS numbers …

Lab#show ip bgp summary | begin Neighbor
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.2.2        4 65100       5       6        4    0    0 00:01:19        1
10.0.3.2        4 65101       5       6        4    0    0 00:01:13        1
10.0.4.2        4 65102       5       6        4    0    0 00:01:16        1

… and the outputs of the show ip bgp command confirm that the three neighbors (implemented as VRFs on the BGP source router) advertise completely independent AS paths.

Lab#show ip bgp
BGP table version is 4, local router ID is 10.0.1.5
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
*> 10.1.1.0/24      10.0.2.2                 0             0 65100 i
*> 10.2.2.0/24      10.0.3.2                 0             0 65101 i
*> 10.3.3.0/24      10.0.4.2                 0             0 65102 i

You can also use show ip bgp vpnv4 vrf name command on the BGP source router to check the BGP routes propagated by the Lab router. For example, the BGP table in VRF C1 has a locally originate prefix as well as two routes received from AS 65101 and AS 65102 via AS 65400:

BGPGen#show ip bgp vpnv4 vrf C1 | begin Network
   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65000:1 (default for vrf C1) VRF Router ID 10.1.1.1
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
*> 10.2.2.0/24      10.0.2.1                               0 64500 65101 i
*> 10.3.3.0/24      10.0.2.1                               0 64500 65102 i

Router configurations

Configuration of the BGP source

hostname BGPGen
!
logging buffered 4096
!
ip subnet-zero
ip vrf C1
 rd 65000:1
 route-target export 65000:1
 route-target import 65000:1
!
ip vrf C2
 rd 65000:2
 route-target export 65000:2
 route-target import 65000:2
!
ip vrf C3
 rd 65000:3
 route-target export 65000:3
 route-target import 65000:3
!
ip cef
!
interface Loopback0
 ip address 10.0.1.4 255.255.255.255
!
interface Loopback1001
 ip vrf forwarding C1
 ip address 10.1.1.1 255.255.255.0
!
interface Loopback1002
 ip vrf forwarding C2
 ip address 10.2.2.1 255.255.255.0
!
interface Loopback1003
 ip vrf forwarding C3
 ip address 10.3.3.1 255.255.255.0
!
interface FastEthernet0/0
 no ip address
 speed auto
 duplex auto
!
interface FastEthernet0/0.100
 encapsulation dot1Q 100
 ip vrf forwarding C1
 ip address 10.0.2.2 255.255.255.0
!
interface FastEthernet0/0.101
 encapsulation dot1Q 101
 ip vrf forwarding C2
 ip address 10.0.3.2 255.255.255.0
!
interface FastEthernet0/0.102
 encapsulation dot1Q 102
 ip vrf forwarding C3
 ip address 10.0.4.2 255.255.255.0
!
router bgp 65200
 no synchronization
 bgp log-neighbor-changes
 no auto-summary
 !
 address-family ipv4 vrf C1
  no synchronization
  bgp router-id auto-assign
  network 10.1.1.0 mask 255.255.255.0
  neighbor 10.0.2.1 remote-as 64500
  neighbor 10.0.2.1 local-as 65100 no-prepend replace-as
  neighbor 10.0.2.1 activate
 exit-address-family
 !
 address-family ipv4 vrf C2
  no synchronization
  bgp router-id auto-assign
  network 10.2.2.0 mask 255.255.255.0
  neighbor 10.0.3.1 remote-as 64500
  neighbor 10.0.3.1 local-as 65101 no-prepend replace-as
  neighbor 10.0.3.1 activate
 exit-address-family
 !
 address-family ipv4 vrf C3
  no synchronization
  bgp router-id auto-assign
  network 10.3.3.0 mask 255.255.255.0
  neighbor 10.0.4.1 remote-as 64500
  neighbor 10.0.4.1 local-as 65102 no-prepend replace-as
  neighbor 10.0.4.1 activate
 exit-address-family
!
ip classless
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 transport preferred none
 stopbits 1
!
ntp logging
end 

Configuration of the lab router

hostname Lab
!
logging buffered 4096
!
ip subnet-zero
!
ip cef
no ip domain lookup
!
interface Loopback0
 ip address 10.0.1.5 255.255.255.255
!
interface FastEthernet0/0
 no ip address
 speed auto
 duplex auto
!
interface FastEthernet0/0.100
 encapsulation dot1Q 100
 ip address 10.0.2.1 255.255.255.0
!
interface FastEthernet0/0.101
 encapsulation dot1Q 101
 ip address 10.0.3.1 255.255.255.0
!
interface FastEthernet0/0.102
 encapsulation dot1Q 102
 ip address 10.0.4.1 255.255.255.0
!
router bgp 64500
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.0.2.2 remote-as 65100
 neighbor 10.0.3.2 remote-as 65101
 neighbor 10.0.4.2 remote-as 65102
 no auto-summary
!
ip classless
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 transport preferred none
 stopbits 1
!
ntp logging
end 

Additional Resources  

Configuring BGP on Cisco Routers (BGP) course
Other links
Personal tools

CT3

Main menu