Cisco Routers Sample BGP Configurations : Quick and Easy
Today I am going to talk about the configurations of BGP on Cisco Routers. I will explain some of the terms which we are going to use in the configurations. Please let me know if you guys required any specific configuration in BGP or you can share the design with us so that we can create the configurations accordingly.
Sometimes if it difficult to set up a BGP configurations in the lab or in the live environment, so here in this article i am just posting the sample configurations which will help you guys to configure BGP in you labs or in the live environment. There is no relevance of this configuration with any of the live networks. All IPs taken in the configuration is just a sample IP addresses taken.
BGP is a wide routing protocol which is used on to connect the WAN links between two different AS. AS stands for autonomous systems. Below is a sample BGP topology and is not relevant what sample configurations shared with you in the below article.
![]() |
Fig 1.1- Sample BGP Topology |
We have two kinds of BGP sessions; one is iBGP which is internal BGP and other is eBGP which is external BGP. Both have different AD values on Cisco routers
- iBGP : 200
- eBGP : 20
Lets start from the beginning, as you all know BGP is a Exterior gateway protocol to connect different routers in the different AS. We are going to showcase the basic configurations in the routers as below.
Basic Configurations
!
interface loopback 0
ip address 115.10.7.1 255.255.255.255
ip address 115.10.7.1 255.255.255.255
!
router bgp 100
network 120.220.1.0
neighbor 115.10.7.2 remote-as 100
neighbor 115.10.7.2 update-source loopback0
neighbor 115.10.7.2 remote-as 100
neighbor 115.10.7.2 update-source loopback0
neighbor 115.10.7.3 remote-as 100
neighbor 115.10.7.3 update-source loopback0
!
External BGP - eBGP
!
interface ethernet 1/0/0
ip address 222.222.10.1 255.255.255.240
ip address 222.222.10.1 255.255.255.240
!
router bgp 101
network 220.220.8.0 mask 255.255.252.0
neighbor 222.222.10.2 remote-as 100
neighbor 222.222.10.2 prefix-list RouterA in
neighbor 222.222.10.2 prefix-list RouterA in
neighbor 222.222.10.2 prefix-list RouterA out
!
Configuring Route Reflector on Cisco Routers
!
router bgp 100
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 route-reflector-client neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 route-reflector-client neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 route-reflector-client neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 route-reflector-client
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 route-reflector-client neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 route-reflector-client neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 route-reflector-client neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 route-reflector-client
!
Configuring Confederations on Cisco Routers
!
router bgp 65532
bgp confederation identifier 200
bgp confederation peers 65530 65531
bgp confederation identifier 200
bgp confederation peers 65530 65531
neighbor 141.153.12.1 remote-as 65530
neighbor 141.153.17.2 remote-as 65531
!
Configuring Weight
!
router bgp 100
neighbor 10.1.1.2 weight 200
!
Configuring Local Preference
!
router bgp 400
neighbor 220.5.1.1 remote-as 300
neighbor 220.5.1.1 route-map local-pref in
neighbor 220.5.1.1 remote-as 300
neighbor 220.5.1.1 route-map local-pref in
!
route-map local-pref permit 10
route-map local-pref permit 10
match ip address prefix-list MATCH
set local-preference 800 !
ip prefix-list MATCH permit 160.10.0.0/16
!
Configuring AS-Path Prepend
!
router bgp 300
network 215.7.0.0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 route-map SETPATH out
!
route-map SETPATH permit 10
route-map SETPATH permit 10
set as-path prepend 300 300
!
Configuring MED
!
router bgp 400
neighbor 220.5.1.1 remote-as 200
neighbor 220.5.1.1 remote-as 200
neighbor 220.5.1.1 route-map set-med out
!
route-map set-med permit 10
route-map set-med permit 10
match ip address prefix-list MATCH
set metric 1000
!
ip prefix-list MATCH permit 192.68.1.0/24
!
Configuring Prefix Lists
!
router bgp 200
neighbor 220.200.1.1 remote-as 210
neighbor 220.200.1.1 prefix-list PEER-IN in
neighbor 220.200.1.1 prefix-list PEER-IN in
neighbor 220.200.1.1 prefix-list PEER-OUT out
!
ip prefix-list PEER-IN deny 218.10.0.0/16
ip prefix-list PEER-IN permit 0.0.0.0/0 le 32
ip prefix-list PEER-IN deny 218.10.0.0/16
ip prefix-list PEER-IN permit 0.0.0.0/0 le 32
ip prefix-list PEER-OUT permit 215.7.0.0/16
!
Route Maps with Prefix Lists
!
router bgp 100
neighbor 1.1.1.1 route-map infilter in
neighbor 1.1.1.1 route-map infilter in
!
route-map infilter permit 10
route-map infilter permit 10
match ip address prefix-list HIGH-PREF
set local-preference 120 !
route-map infilter permit 20
match ip address prefix-list LOW-PREF set local-preference 80
match ip address prefix-list LOW-PREF set local-preference 80
!
route-map infilter permit 30
!
ip prefix-list HIGH-PREF permit 10.0.0.0/8
route-map infilter permit 30
!
ip prefix-list HIGH-PREF permit 10.0.0.0/8
ip prefix-list LOW-PREF permit 20.0.0.0/8
!
Route Maps with Filter Lists
!
router bgp 100
neighbor 220.200.1.2 route-map filter-on-as-path in
neighbor 220.200.1.2 route-map filter-on-as-path in
!
route-map filter-on-as-path permit 10
route-map filter-on-as-path permit 10
match as-path 1
set local-preference 80 !
route-map filter-on-as-path permit 20 match as-path 2
set local-preference 200
set local-preference 200
!
route-map filter-on-as-path permit 30 !
ip as-path access-list 1 permit _150$
route-map filter-on-as-path permit 30 !
ip as-path access-list 1 permit _150$
ip as-path access-list 2 permit _210_
!
Configuring Regular Expression
!
router bgp 100
neighbor 220.200.1.1 remote-as 210
neighbor 220.200.1.1 filter-list 5 out
neighbor 220.200.1.1 filter-list 6 in
!
ip as-path access-list 5 permit ^200$
ip as-path access-list 5 permit ^200$
ip as-path access-list 6 permit ^150$
!
Configuring Communities
!
router bgp 100
neighbor 220.200.1.1 remote-as 200
neighbor 220.200.1.1 send-community
neighbor 220.200.1.1 route-map set-community out
neighbor 220.200.1.1 send-community
neighbor 220.200.1.1 route-map set-community out
!
route-map set-community permit 10
route-map set-community permit 10
match ip address prefix-list NO-ANNOUNCE
set community no-export !
route-map set-community permit 20
!
ip prefix-list NO-ANNOUNCE permit 172.168.0.0/16 ge 17
!
ip prefix-list NO-ANNOUNCE permit 172.168.0.0/16 ge 17
!
Configuring iBGP Peer-Group with Route-Maps
!
router bgp 100
neighbor ibgp-peer peer-group
neighbor ibgp-peer remote-as 100
neighbor ibgp-peer update-source loopback 0
router bgp 100
neighbor ibgp-peer peer-group
neighbor ibgp-peer remote-as 100
neighbor ibgp-peer update-source loopback 0
neighbor ibgp-peer send-community
neighbor ibgp-peer route-map outfilter out
neighbor ibgp-peer route-map outfilter out
neighbor 1.1.1.1 peer-group ibgp-peer
neighbor 2.2.2.2 peer-group ibgp-peer
neighbor 2.2.2.2 route-map infilter in
neighbor 3.3.3.3 peer-group ibgp-peer
!
Configuring External Peer Group with Route-Maps
!
router bgp 100
neighbor external-peer peer-group
neighbor external-peer send-community
neighbor external-peer route-map set-metric out
neighbor external-peer peer-group
neighbor external-peer send-community
neighbor external-peer route-map set-metric out
neighbor 160.89.1.2 remote-as 200
neighbor 160.89.1.2 peer-group external-peer
neighbor 160.89.1.2 peer-group external-peer
neighbor 160.89.1.4 remote-as 300
neighbor 160.89.1.4 peer-group external-peer
neighbor 160.89.1.4 peer-group external-peer
neighbor 160.89.1.6 remote-as 400
neighbor 160.89.1.6 peer-group external-peer
neighbor 160.89.1.6 peer-group external-peer
neighbor 160.89.1.6 filter-list infilter in
!
BGP Soft Re-configuration
!
router bgp 100
neighbor 1.1.1.1 remote-as 101
neighbor 1.1.1.1 route-map infilter in neighbor 1.1.1.1 soft-reconfiguration inbound
neighbor 1.1.1.1 remote-as 101
neighbor 1.1.1.1 route-map infilter in neighbor 1.1.1.1 soft-reconfiguration inbound
clear ip bgp 1.1.1.1 soft [in | out]
!