如果本文對你有幫助,歡迎關注、讨論、點贊、收藏、轉發給朋友,讓我有持續創作的動力,讓我們一起互相學習共同進步。
BGP簡單實驗配置
實驗拓撲:
要求:
BGP動态路由實驗:
4台路由器基礎名稱,接口IP均配置
(1).4台PC分别在4個不同網段:
- PC1:10.1.1.0/24
- PC2: 10.1.2.0/24
- PC3: 10.2.3.0/25
- PC4: 10.2.4.0/25
(2).4台路由器loopback0位址分别是:
- R1:1.1.1.1/32
- R2:2.2.2.2/32
- R3:3.3.3.3/32
- R4:4.4.4.4/32
(3).路由器之間中繼鍊路使用接口位址為:192.168.0.0/16,已經有基礎配置。
組網要求使用BGP動态路由方式:
- R1和R2屬AS 100域,R3和R4屬AS200。
- R1和R3之間起EBGP協定,域内都起IBGP協定。
- 4台路由器loopback0位址可互通。
- 域間路由釋出使用者路由必須通過EBGP。
- R1和R3分别向R2和R4釋出預設路由。
- PC2所在位址段10.1.2.0/24隻能和域内位址互通。
- R3隻能向R1釋出PC3和PC4的彙總路由:10.2.0.0/16。
實驗配置步驟:
- 配置IP編址
- 配置AS内IGP連通性
- 配置IBGP
- 配置EBGP
- 配置路由聚合
- 配置路由引入政策,是的PC2隻能域内互通
- 驗證
一、配置IP編址:
R1:
#
interface GigabitEthernet0/0/0
description R1-R3-GE0/0/0
ip address 192.168.13.1 255.255.255.252
#
interface GigabitEthernet0/0/1
description R1-R2
ip address 192.168.12.1 255.255.255.252
#
interface GigabitEthernet1/0/0
description R1-R3-GE1/0/0
ip address 192.168.13.5 255.255.255.252
#
interface GigabitEthernet5/0/0
description R1-PC1
ip address 10.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
R2:
#
interface GigabitEthernet0/0/1
description R2-R1
ip address 192.168.12.2 255.255.255.252
#
interface GigabitEthernet5/0/0
description R2-PC2
ip address 10.1.2.1 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
R3:
#
interface GigabitEthernet0/0/0
description R3-R1-GE0/0/0
ip address 192.168.13.2 255.255.255.252
#
interface GigabitEthernet0/0/1
description R3-R4-GE0/0/1
ip address 192.168.34.1 255.255.255.252
#
interface GigabitEthernet1/0/0
description R3-R1-GE1/0/0
ip address 192.168.13.6 255.255.255.252
#
interface GigabitEthernet5/0/0
description R3-PC3
ip address 10.2.3.2 255.255.255.128
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
R4:
#
interface GigabitEthernet0/0/1
description R4-R3-GE0/0/1
ip address 192.168.34.2 255.255.255.252
#
interface GigabitEthernet5/0/0
description R4-PC4
ip address 10.2.4.1 255.255.255.128
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
配置完成後測試位址直連位址連通性:此處不一一測試。
二、配置IGP連通性
AS100内運作OSPF,AS200内采用靜态路由保證R3、R4的loopback 0 位址互通。具體配置如下:
AS100内:
R1:
#
ospf 1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 192.168.12.0 0.0.0.255
#
R2:
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 192.168.12.0 0.0.0.255
area 0.0.0.12
#
AS200内:
R3:
#
ip route-static 4.4.4.4 255.255.255.255 192.168.34.2
#
R4:
#
ip route-static 3.3.3.3 255.255.255.255 192.168.34.1
#
三:配置IBGP
R1:
#
bgp 100
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 1.1.1.1 255.255.255.255
network 10.1.1.0 255.255.255.0
peer 2.2.2.2 enable
#
R2:
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 2.2.2.2 255.255.255.255
network 10.1.2.0 255.255.255.0
peer 1.1.1.1 enable
#
R3:
#
bgp 200
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
network 3.3.3.3 255.255.255.255
network 10.2.3.0 255.255.255.128
peer 4.4.4.4 enable
peer 4.4.4.4 default-route-advertise
#
R4:
#
bgp 200
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 4.0.0.0
network 4.4.4.4 255.255.255.255
network 10.2.4.0 255.255.255.128
peer 3.3.3.3 enable
#
注意:BGP為保證路由下一跳的可達性,需要将IGP路由與EGP路由同步。故,需在R1,R3上将IGP協定路由引入。
R1:
#
bgp 100
import-route direct
import-route static
import-route ospf 1
#
R3:
#
bgp 200
import-route direct
import-route static
#
四、配置EBGP
此處采用loopback口進行EBGP鄰居的搭建,也可用直連口進行EBGP鄰居建立,直連口建立鄰居關系更簡單。具體配置如下:
R1:
#
ip route-static 3.3.3.3 255.255.255.255 192.168.13.2
ip route-static 3.3.3.3 255.255.255.255 192.168.13.6 #保證路由的可達性,BGP為TCP協定,需三層可達才能建立BGP鄰居關系。
#
bgp 100
peer 3.3.3.3 as-number 200
peer 3.3.3.3 ebgp-max-hop 2 #EBGP鄰居建立是,預設TTL值為1,利用loopback口建立鄰居關系是由于loopback口之間不是直連,故需要改變EBGP鄰居的多跳可達屬性。
peer 3.3.3.3 connect-interface LoopBack0
#
R3:
#
ip route-static 1.1.1.1 255.255.255.255 192.168.13.1
ip route-static 1.1.1.1 255.255.255.255 192.168.13.5
#
bgp 200
peer 1.1.1.1 as-number 100
peer 1.1.1.1 ebgp-max-hop 2
peer 1.1.1.1 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
network 3.3.3.3 255.255.255.255
network 10.2.3.0 255.255.255.128
peer 1.1.1.1 enable
peer 4.4.4.4 default-route-advertise 向R4釋出預設路由
#
五、配置路由聚合
#
bgp 200
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
#
驗證:在R1上檢視是否有10.2.3.0或者10.2.4.0網段
六、配置路由引入政策,是的PC2隻能域内互通
R2:
#
ip ip-prefix PC2 index 10 deny 10.2.0.0 16
ip ip-prefix PC2 index 20 permit 0.0.0.0 0 less-equal 32
#
bgp 100
peer 1.1.1.1 ip-prefix PC2 import
#
七、驗證
R1:
R2:
R3:
R4:
PC2:
PC1:
PC3:
PC4: