这次基本配置实验涉及以下几个问题:
1.建立IBGP和EBGP邻居
2.回环口的EBGP邻居的建立
3.发布IBGP和EBGP路由
4.IBGP的同步问题
5.路由黑洞及其解决
6.路由反射器
7.路由汇总(原子汇聚)
8.团体属性(共同体属性)以及在IBGP中的传播
9.对等体组的配置
一下实验都是在dynamic上用如下信息的IOS做的实验,仅供参考。
Cisco IOS Software, 3600 Software (C3640-IK9O3S-M), Version 12.4(10), RELEASE SOFTWARE (fc1)
一.建立IBGP和EBGP邻居
拓扑图如上所示,我们使用RIPv2作为IGP,跑在R2 R3 R4的物理接口上。
下面是五个路由器的基本配置,通过基本配置我们可以建立起IBGP和EBGP的邻居。
1.配置
r1#sh run
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 40.1.1.1 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 10.1.1.1 255.255.255.0
half-duplex
!
router bgp 20
no synchronization
bgp log-neighbor-changes
neighbor 10.1.1.2 remote-as 10
neighbor 40.1.1.4 remote-as 10
no auto-summary
r2#sh run
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
ip address 20.1.1.2 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 10.1.1.2 255.255.255.0
half-duplex
!
router rip
version 2
network 10.0.0.0
network 20.0.0.0
no auto-summary
!
router bgp 10
no synchronization
bgp log-neighbor-changes
neighbor 10.1.1.1 remote-as 20
neighbor 20.1.1.3 remote-as 10
neighbor 40.1.1.4 remote-as 10
no auto-summary
r3#sh run
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Ethernet0/0
ip address 20.1.1.3 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 30.1.1.3 255.255.255.0
half-duplex
!
router rip
version 2
network 20.0.0.0
network 30.0.0.0
no auto-summary
!
router bgp 10
no synchronization
bgp log-neighbor-changes
neighbor 20.1.1.2 remote-as 10
neighbor 30.1.1.4 remote-as 10
no auto-summary
r4#sh run
interface Loopback0
ip address 192.168.1.1 255.255.255.252
!
interface Loopback1
ip address 192.168.1.5 255.255.255.252
!
interface Loopback2
ip address 192.168.1.9 255.255.255.252
!
interface Ethernet0/0
ip address 40.1.1.4 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 30.1.1.4 255.255.255.0
half-duplex
!
interface Ethernet0/2
ip address 50.1.1.4 255.255.255.0
half-duplex
!
router rip
version 2
network 30.0.0.0
network 40.0.0.0
network 50.0.0.0
no auto-summary
!
router bgp 10
no synchronization
bgp log-neighbor-changes
neighbor 20.1.1.2 remote-as 10
neighbor 30.1.1.3 remote-as 10
neighbor 40.1.1.1 remote-as 20
neighbor 50.1.1.5 remote-as 30
no auto-summary
r5#sh run
interface Loopback0
ip address 5.5.5.5 255.255.255.0
!
interface Ethernet0/2
ip address 50.1.1.5 255.255.255.0
half-duplex
!
router bgp 30
no synchronization
bgp log-neighbor-changes
neighbor 50.1.1.4 remote-as 10
no auto-summary
2.验证
r2#sh ip bgp sum
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.1 4 20 19 18 12 0 0 00:11:52 1
20.1.1.3 4 10 18 17 12 0 0 00:12:19 5
30.1.1.4 4 10 7 6 12 0 0 00:00:48 5
r4#sh ip bgp sum
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
20.1.1.2 4 10 6 7 9 0 0 00:00:08 2
30.1.1.3 4 10 17 17 9 0 0 00:11:45 3
40.1.1.1 4 20 19 18 9 0 0 00:11:38 1
50.1.1.5 4 30 15 18 9 0 0 00:11:46 1
二.回环口的EBGP邻居的建立
使用回环口建立邻居有各种好处,不过两个问题:
一是需要制定update-source端口。
二是EBGP邻居hello包默认TTL为1,所以我们要修改使其能通过回环口建立邻居。
我们以R4与R5之间建立第二条邻居关系为例,建立多条邻居一般作为备份链路等作用。
后面的实验没有用到回环口邻居所以后面把它关闭,仅仅在这个部分演示。
1.配置
r4#
ip route 5.5.5.0 255.255.255.0 Ethernet0/2
neighbor 5.5.5.5 remote-as 30
neighbor 5.5.5.5 ebgp-multihop 2
neighbor 5.5.5.5 update-source Loopback0
r5#
ip route 192.168.1.0 255.255.255.0 Ethernet0/2
neighbor 192.168.1.1 remote-as 10
neighbor 192.168.1.1 ebgp-multihop 2
neighbor 192.168.1.1 update-source Loopback0
2.验证
r5# sh ip bgp sum
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
50.1.1.4 4 10 32 28 8 0 0 00:24:01 6
192.168.1.1 4 10 13 13 8 0 0 00:05:34 6
三.发布IBGP和EBGP路由
1.配置
r1#
network 1.1.1.0 mask 255.255.255.0
r2#
network 2.2.2.0 mask 255.255.255.0
r3#
network 3.3.3.0 mask 255.255.255.0
r4#
network 192.168.1.0 mask 255.255.255.252
network 192.168.1.4 mask 255.255.255.252
network 192.168.1.8 mask 255.255.255.252
r5#
network 5.5.5.0 mask 255.255.255.0
2.验证
由于新版本ios默认关闭同步,所以现在所有路由全都能学习到。
r1>sh ip route b
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [20/0] via 10.1.1.2, 00:27:17
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 40.1.1.4, 00:27:18
5.0.0.0/24 is subnetted, 1 subnets
B 5.5.5.0 [20/0] via 10.1.1.2, 00:03:42
192.168.1.0/30 is subnetted, 3 subnets
B 192.168.1.8 [20/0] via 40.1.1.4, 00:27:18
B 192.168.1.0 [20/0] via 40.1.1.4, 00:27:18
B 192.168.1.4 [20/0] via 40.1.1.4, 00:27:18
r2>sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 10.1.1.1, 00:27:38
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 20.1.1.3, 00:27:38
5.0.0.0/24 is subnetted, 1 subnets
B 5.5.5.0 [200/0] via 50.1.1.5, 00:04:03
192.168.1.0/30 is subnetted, 3 subnets
B 192.168.1.8 [200/0] via 30.1.1.4, 00:17:05
B 192.168.1.0 [200/0] via 30.1.1.4, 00:17:05
B 192.168.1.4 [200/0] via 30.1.1.4, 00:17:05
r3>sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [200/0] via 10.1.1.1, 00:27:51
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 20.1.1.2, 00:27:51
5.0.0.0/24 is subnetted, 1 subnets
B 5.5.5.0 [200/0] via 50.1.1.5, 00:04:16
192.168.1.0/30 is subnetted, 3 subnets
B 192.168.1.8 [200/0] via 30.1.1.4, 00:28:18
B 192.168.1.0 [200/0] via 30.1.1.4, 00:28:18
B 192.168.1.4 [200/0] via 30.1.1.4, 00:28:18
r4#sh ip route bg
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 40.1.1.1, 00:27:01
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 20.1.1.2, 00:16:28
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 30.1.1.3, 00:27:28
r5#sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 50.1.1.4, 00:28:21
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [20/0] via 50.1.1.4, 00:28:21
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 50.1.1.4, 00:28:51
192.168.1.0/24 is variably subnetted, 4 subnets, 2 masks
B 192.168.1.8/30 [20/0] via 50.1.1.4, 00:28:51
B 192.168.1.0/30 [20/0] via 50.1.1.4, 00:28:51
B 192.168.1.4/30 [20/0] via 50.1.1.4, 00:28:51
四.IBGP的同步问题
当我们把同步打开的时候,出现这样的情况:
r1#sh ip route b
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [20/0] via 10.1.1.2, 00:04:54
192.168.1.0/30 is subnetted, 3 subnets
B 192.168.1.8 [20/0] via 40.1.1.4, 00:04:54
B 192.168.1.0 [20/0] via 40.1.1.4, 00:04:54
B 192.168.1.4 [20/0] via 40.1.1.4, 00:04:54
r2#sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 10.1.1.1, 00:34:58
r3#sh ip route b
r4#sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 40.1.1.1, 00:34:49
r5#sh ip route b
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [20/0] via 50.1.1.4, 00:35:05
192.168.1.0/24 is variably subnetted, 4 subnets, 2 masks
B 192.168.1.8/30 [20/0] via 50.1.1.4, 00:35:35
B 192.168.1.0/30 [20/0] via 50.1.1.4, 00:35:35
B 192.168.1.4/30 [20/0] via 50.1.1.4, 00:35:35
IBGP无法互传路由,因为同样的路由必须从IGP中学到(如果是ospf router-id还需相同)
同样也无法传递EIGP路由。
解决方法,全局跑IGP或者将BGP重分布到IGP。
redistribution bgp 10
同样,后面的实验将关闭同步
五.路由黑洞及其解决
关闭了同步,在IBGP中就可能出现黑洞。
例如,如果如第二部分实验所示,在r5上只用lo0口的5.5.5.5做邻居,且宣告一条55.55.55.55的路由到BGP
r4会学到这样一条路由:
55.55.55.0/24 is subnetted, 1 subnets
B 55.55.55.0 [20/0] via 5.5.5.5, 00:34:49
r3会学到这样一条路由更新,但不会放到路由表中,因为next-hop不可达。
Network Next Hop Metric LocPrf Weight Path
* i55.55.55.0/24 5.5.5.5 0 100 0 20
解决方法,在r4上配置:neighbor 30.1.1.3 next-hop-self
或者通过静态路由、将EIGP重分布进IGP等方法。
六.路由反射器
现在IBGP路由处在full mesh全互联状态,当我们断开r2和r4的邻居关系,就会学不到对方的BGP路由。
一种解决方法,配置路由反射器。
r3(config-router)#nei 20.1.1.2 route-reflector-client
r3(config-router)#nei 30.1.1.4 route-reflector-client
七.路由汇总(原子汇聚)
将r4的三个回环口配置端口聚合:
r4(config-router)#aggregate-address 192.168.1.0 255.255.255.0
八.团体属性(共同体属性)以及在IBGP中的传播
四类组属性:no-advertise no-export internet 以及 local-as
我们不想把as30的路由通告给其他区域。
access-list 10 permit 5.5.5.0 0.0.0.255
!
route-map noexport permit 10
match ip address 10
set community no-export
neighbor 50.1.1.4 send-community
neighbor 50.1.1.4 route-map noexport out
这样我们在r4上看到了这样的条目
r4#sh ip bgp 5.5.5.0
BGP routing table entry for 5.5.5.0/24, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer, RIB-failure(17))
Advertised to update-groups:
2 3
30
50.1.1.5 from 50.1.1.5 (5.5.5.5)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: no-export
但是r1还是能学到5.5.5.0的路由条目
很多很多实验在做组属性的时候,每个AS都只有一台BGP路由器,这样就不能说明组属性在IBGP中的传递。
我们现在在r3上看不到no-export,所以需要向每个转发IBGP宣告发出community属性
在有反射器的AS中也是一样,每一步都需要向下宣告。
r4(config-router)#neighbor 30.1.1.3 send-community
r3(config-router)#neighbor 20.1.1.2 send-community
九.对等体组的配置
这个比较简单,建立组加入组即可。
创建组
neighbor T_T peer-group
加入组
neighbor 30.1.1.3 peer-group T_T
布置属性
neighbor T_T send-community




评论