BGP基本配置

BGP第一次實驗內容
實驗目的
1. 瞭解BGP的基本配置
2. 瞭解multihop,next-hop-self的配置方法
3. 瞭解BGP中local preference和MED的概念與配置方法

實驗設備
cisco1720 ----5臺

試驗拓撲:


     172.16.2.1/24                 172.16.2.2/24   172.16.4.1/24

as100b                            as100c

172.16.1.2/24                  172.16. 5.2          172.16.3.1/24



                172.16.1.1/24      172.16.5.1/24                            172.16.3.2/24 as300-d        192.168.1,2/24

                       as65500a                                                               192.168.1.1/24                   as300-e

                        10.10.1.1/24                                                                                                         192.168.2.1/24


基本配置路由器,並啓動BGP協議

as65500-A:

hostname as65500-a
!
enable password cisco
!
interface Loopback1
ip address 10.10.1.1 255.255.255.0
!
interface Serial0
ip address 172.16.1.1 255.255.255.0
!
interface Serial1
ip address 172.16.5.1 255.255.255.0
!
router bgp 65500
no synchronization
network 10.10.1.0 mask 255.255.255.0
network 172.16.1.0 mask 255.255.255.0
network 172.16.5.0 mask 255.255.255.0
neighbor 172.16.1.2 remote-as 100
neighbor 172.16.5.2 remote-as 100
no auto-summary
!
line vty 0 4
password cisco
login


as100-B:
hostname as100-b
!
enable password cisco
!
interface Serial0
ip address 172.16.2.1 255.255.255.0
clockrate 56000
!
interface Serial1
ip address 172.16.1.2 255.255.255.0
clockrate 56000
!
router rip
version 2
network 172.16.0.0
!
router bgp 100
no synchronization
network 172.16.1.0 mask 255.255.255.0
network 172.16.2.0 mask 255.255.255.0
neighbor 172.16.1.1 remote-as 65500
neighbor 172.16.2.2 remote-as 100
!
line vty 0 4
password cisco
login
!

as100-C:
hostname AS100-C
!
enable password cisco
!
interface Loopback1
ip address 172.16.4.1 255.255.255.0
!
interface FastEthernet0/0
ip address 172.16.3.1 255.255.255.0
!
interface Serial0/0
ip address 172.16.2.2 255.255.255.0
!
interface Serial0/1
ip address 172.16.5.2 255.255.255.0
!
router rip
version 2
network 172.16.0.0
!
router bgp 100
no synchronization
network 172.16.2.0 mask 255.255.255.0
network 172.16.3.0 mask 255.255.255.0
network 172.16.4.0 mask 255.255.255.0
network 172.16.5.0 mask 255.255.255.0
neighbor 172.16.2.1 remote-as 100
neighbor 192.168.1.2 remote-as 300
neighbor 172.16.5.1 remote-as 65500
!
line vty 0 4
password cisco
login


as300-D
!
hostname AS300-D
!
enable password cisco
!
interface FastEthernet0/0
ip address 172.16.3.2 255.255.255.0
!
interface Serial0/0
ip address 192.168.1.1 255.255.255.0
!
router eigrp 300
network 192.168.1.0
!
ip route 0.0.0.0 0.0.0.0 172.16.3.1
line vty 0 4
password cisco
login
!

as300-E
hostname AS300-E
!
enable password cisco
!
interface Loopback0
ip address 192.168.2.1 255.255.255.0
!
interface Serial0/0
ip address 192.168.1.2 255.255.255.0
!
router eigrp 300
network 192.168.1.0
network 192.168.2.0
!
router bgp 300
network 192.168.1.0
network 192.168.2.0
neighbor 172.16.3.1 remote-as 100
!
line vty 0 4
password cisco
login
!
基本配置好路由器後,查看路由器運行BGP協議的情況。用show ip bgp查看bgp表,用show ip route 查看路由表

multihop
as100-C與as300-E之間不能成功建立bgp鄰居關係,是因爲as300中,as300-D路由器並不運行 bgp協議,所以我們需要在AS300-E與AS100-C兩臺路由器上附加multihop配置.靜態路由的添加是爲了這兩臺路由器之間能通過 tcp/ip協議互相訪問,這樣bgp協議才能正常工作.
具體配置如下:
as100-C:
router bgp 100
neighbor 192.168.1.2 remote-as 300
 neighbor 192.168.1.2 ebgp-multihop 2
!
ip route 192.168.1.0 255.255.255.0 172.16.3.2
!

as300-E
router bgp 300
neighbor 172.16.3.1 remote-as 100
neighbor 172.16.3.1 ebgp-multihop 2
!
ip route 172.16.3.0 255.255.255.0 192.168.1.1
!

理解next-hop-self
通過以上配置,全部bgp鄰居都建立起來了.觀察bgp表,能看到全部網段的信息.但在路由表中,發現 as100-B路由器並沒有192.168.1.0和192.168.2.0網段的信息.是因爲,as100-B並不知道192.168.1.2在哪裏, 所以不會把通過這個路由學來的bgp路由放到路由表中.我們需要通過next-hop-self配置,讓as100-B獲得的192.168.1.0和 192.168.2.0網段信息不再是從192.168.1.2獲得,而是從172.16.2.2獲得,這樣as100-B就會把這條bgp路由放到路由 表中了.
配置next-hop-self前請看清楚bgp表與路由表,並與配置後的作對比
具體配置爲
as100-C
router bgp 100
neighbor 172.16.2.1 next-hop-self
!

通過以上配置,我們配通了全部bgp協議,請用ping命令檢查網絡全部正常運行.

配置本地優先
本地優先是指as內部路由器控制自己as幾個出口的優先級.比如as65500有兩個出口,那麼到底選擇哪個作爲優先呢,我們可以通過配置本地優先來控制.

as65500-a:
router bgp 65500
 no synchronization
network 10.10.1.0 mask 255.255.255.0
network 172.16.1.0 mask 255.255.255.0
 network 172.16.5.0 mask 255.255.255.0
 neighbor 172.16.1.2 remote-as 100
 neighbor 172.16.5.2 remote-as 100
 neighbor 172.16.5.2 route-map setlocalpre in
!
route-map setlocalpre permit 10
set local-preference 200
!
!
line vty 0 4
password cisco
login
!

配置後,用clear ip bgp *從起bgp協議,並用show ip bgp和show ip route查看結果


配置MED
配置MED是一個as用來控制其他as從哪個入口進來本as的方法,比如as100上,能通過配置MED,使as65500優先選擇其中一條路徑進入as100:

在as100-C上配置

router bgp 100
neighbor 172.16.5.1 remote-as 65500
neighbor 172.16.5.1 route-map setmed out
!
route-map setmed permit 10
set metric 100
!
配置後,用clear ip bgp *從起bgp協議,並用show ip bgp和show ip route查看結果


去掉保留AS
在AS號碼中65001後面的是保留AS部分,一般用作ISP內部分配用,所以在廣域網上面得去掉保留得AS號碼.在這裏,65500是保留AS,所以as100-C發送給as300-E的時候,應該去掉這個AS,具體配置爲:
as100-C
router bgp 100
neighbor 192.168.1.2 remove-private-as

配置後,用clear ip bgp *從起bgp協議,並用show ip bgp和show ip route查看結果


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章