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动态路由方式:
1.R1和R2属AS 100域,R3和R4属AS200。
2.R1和R3之间起EBGP协议,域内都起IBGP协议。
3.4台路由器loopback0地址可互通。
4.域间路由发布用户路由必须通过EBGP。
5.R1和R3分别向R2和R4发布默认路由。
6.PC2所在地址段10.1.2.0/24只能和域内地址互通。
7.R3只能向R1发布PC3和PC4的汇总路由:10.2.0.0/16。
实验配置步骤:
一、配置IP编址
二、配置AS内IGP连通性
三、配置IBGP
四、配置EBGP
五、配置路由聚合
六、配置路由引入策略,是的PC2只能域内互通
七、验证
一、配置IP编址:
R1:
#interface GigabitEthernet0/0/0description R1-R3-GE0/0/0ip address 192.168.13.1 255.255.255.252 #interface GigabitEthernet0/0/1description R1-R2ip address 192.168.12.1 255.255.255.252 #interface GigabitEthernet1/0/0description R1-R3-GE1/0/0ip address 192.168.13.5 255.255.255.252 #interface GigabitEthernet5/0/0description R1-PC1ip address 10.1.1.1 255.255.255.0 #interface LoopBack0ip address 1.1.1.1 255.255.255.255 #
R2:
#interface GigabitEthernet0/0/1description R2-R1ip address 192.168.12.2 255.255.255.252 #interface GigabitEthernet5/0/0description R2-PC2ip address 10.1.2.1 255.255.255.0 #interface LoopBack0ip address 2.2.2.2 255.255.255.255 #
R3:
#interface GigabitEthernet0/0/0description R3-R1-GE0/0/0ip address 192.168.13.2 255.255.255.252 #interface GigabitEthernet0/0/1description R3-R4-GE0/0/1ip address 192.168.34.1 255.255.255.252 #interface GigabitEthernet1/0/0description R3-R1-GE1/0/0ip address 192.168.13.6 255.255.255.252 #interface GigabitEthernet5/0/0description R3-PC3ip address 10.2.3.2 255.255.255.128 #interface LoopBack0ip address 3.3.3.3 255.255.255.255 #
R4:
#interface GigabitEthernet0/0/1description R4-R3-GE0/0/1ip address 192.168.34.2 255.255.255.252 #interface GigabitEthernet5/0/0description R4-PC4ip address 10.2.4.1 255.255.255.128 #interface LoopBack0ip 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 100peer 2.2.2.2 as-number 100 peer 2.2.2.2 connect-interface LoopBack0#ipv4-family unicastundo synchronizationnetwork 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 100peer 1.1.1.1 as-number 100 peer 1.1.1.1 connect-interface LoopBack0#ipv4-family unicastundo synchronizationnetwork 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 200peer 4.4.4.4 as-number 200peer 4.4.4.4 connect-interface LoopBack0#ipv4-family unicastundo synchronizationaggregate 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.128peer 4.4.4.4 enablepeer 4.4.4.4 default-route-advertise#
R4:
#bgp 200peer 3.3.3.3 as-number 200peer 3.3.3.3 connect-interface LoopBack0#ipv4-family unicastundo synchronizationnetwork 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 100import-route directimport-route staticimport-route ospf 1#
R3:
#bgp 200import-route directimport-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 100peer 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.1ip route-static 1.1.1.1 255.255.255.255 192.168.13.5#bgp 200peer 1.1.1.1 as-number 100peer 1.1.1.1 ebgp-max-hop 2 peer 1.1.1.1 connect-interface LoopBack0ipv4-family unicastundo synchronizationaggregate 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 enablepeer 4.4.4.4 default-route-advertise向R4发布默认路由#
五、配置路由聚合
#bgp 200aggregate 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 16ip ip-prefix PC2 index 20 permit 0.0.0.0 0 less-equal 32#bgp 100peer 1.1.1.1 ip-prefix PC2 import#
七、验证
R1:
R2:
R3:
R4:
PC2:
PC1:
PC3:
PC4: