搜档网
当前位置:搜档网 › BGP和OSPF在路由重分发时的注意点

BGP和OSPF在路由重分发时的注意点

BGP和OSPF在路由重分发时的注意点
BGP和OSPF在路由重分发时的注意点

RGNOSv10.3(3)

BGP和OSPF在路由重分发时的注意点

2008-5-15

福建星网锐捷网络有限公司

版权所有侵权必究

前言

本文档介绍了RGNOS V10.3(3)中BGP和OSPF路由重发布时的一些

实现特点。

由于这些特点区别于友商CISCO的BGP功能实现,在具体的项目实

施过程中需要注意。

1.?本文档仅限公司内部使用,严禁外传。

1.?如果您在阅读中产生疑问,请与文档维护人联系。

目录

1. 1OSPF重分发BGP路由1. 1.1注意点

1. 这里Cisco验证的版本为c7200-adventerprisek9-mz.124-9.T1.bin

2. 1.2应用实例

1. 1.

2.1网络拓扑

四台设备之间建立EBGP/IBGP/EBGP连接。C1为CISCO 3550、C2、

C3是Cisco模拟器,R1是我司设备,实验设备为RG-S5750。C1和

R1建立EBGP连接,R1和C2建立IBGP连接,C2和C3建立EBGP

连接。其中C1和C3主要是发送路由,具体的操作在R1和C2。2. 1.2.2配置文件

C1 简化配置

C1#sho running-config

Building configuration...

Current configuration : 2557 bytes

!

version 12.2

no service pad

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname C1

!

!

no aaa new-model

ip subnet-zero

ip routing

!

!

!

!

!

!

no file verify auto

spanning-tree mode pvst

spanning-tree extend system-id

!

vlan internal allocation policy ascending

!

!

interface Loopback0

ip address 1.1.1.1 255.255.255.255

!

interface FastEthernet0/1

no switchport

ip address 192.168.16.1 255.255.255.248

!

interface FastEthernet0/2

switchport mode dynamic desirable

!

interface FastEthernet0/3

switchport mode dynamic desirable

!

...

!

router bgp 1

no synchronization

bgp log-neighbor-changes

redistribute static

neighbor 192.168.16.2 remote-as 23

no auto-summary

!

ip classless

ip route 192.168.111.0 255.255.255.0 Loopback0

ip route 192.168.112.0 255.255.255.0 Loopback0

ip http server

ip http secure-server

!

!

!

control-plane

!

!

line con 0

line vty 0 4

privilege level 15

password w

login

!

!

end

C1#

C2简化配置

C2#sho runn

Building configuration...

Current configuration : 1450 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname C2

!

boot-start-marker

warm-reboot

boot-end-marker

!

!

no aaa new-model

!

resource policy

!

ip cef

!

!

!

!

interface Loopback0

ip address 192.168.125.1 255.255.255.0 secondary ip address 192.168.126.1 255.255.255.0 secondary ip address 2.2.2.2 255.255.255.255

!

interface FastEthernet0/0

ip address 192.168.26.2 255.255.255.248

duplex full

!

interface Ethernet1/0

no ip address

shutdown

duplex half

!

interface Ethernet1/1

no ip address

shutdown

duplex half

!

interface Ethernet1/2

no ip address

shutdown

duplex half

!

interface Ethernet1/3

ip address 192.168.23.1 255.255.255.248

duplex full

!

router ospf 1

log-adjacency-changes

network 2.2.2.2 0.0.0.0 area 0

network 192.168.26.0 0.0.0.7 area 0

!

router bgp 23

no synchronization

bgp log-neighbor-changes

network 192.168.125.0

network 192.168.126.0

neighbor 6.6.6.6 remote-as 23

neighbor 6.6.6.6 update-source Loopback0

neighbor 6.6.6.6 next-hop-self

neighbor 192.168.23.2 remote-as 3

no auto-summary

!

no ip http server

no ip http secure-server

!

!

...

!

line con 0

stopbits 1

line aux 0

line vty 0 4

privilege level 15

password w

login

!

!

end

C2#

C3简化配置

C3#sho runn

Building configuration...

Current configuration : 1178 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname C3

!

boot-start-marker

boot-end-marker

!

!

no aaa new-model

!

resource policy

!

ip cef

!

!

!

!

!

!

interface Loopback0

ip address 3.3.3.3 255.255.255.255

!

interface FastEthernet0/0

no ip address

shutdown

duplex full

!

interface Ethernet1/0

no ip address

shutdown

duplex half

!

interface Ethernet1/1

no ip address

shutdown

duplex half

!

interface Ethernet1/2

no ip address

shutdown

duplex half

!

interface Ethernet1/3

ip address 192.168.23.2 255.255.255.248

duplex full

!

router bgp 3

no synchronization

bgp log-neighbor-changes

redistribute static

neighbor 192.168.23.1 remote-as 23

no auto-summary

!

ip route 192.168.131.0 255.255.255.0 Loopback0

ip route 192.168.132.0 255.255.255.0 Loopback0

no ip http server

no ip http secure-server

!

!

!

logging alarm informational

!

...

!

line con 0

stopbits 1

line aux 0

line vty 0 4

privilege level 15

password w

login

!

!

end

C2#

R1简化配置

R1#show runn

Building configuration...

Current configuration : 2080 bytes

!

version RGNOS 10.3.00(3), Release(38105)(Fri Apr 25 15:29:44 CST 2008 -ngcf31)

hostname R1

co-operate enable

!

!

!

!

route-map ospf_redist permit 10

match route-type external

!

vlan 1

!

!

!

!

!

interface GigabitEthernet 0/1

no switchport

no ip proxy-arp

ip address 192.168.26.1 255.255.255.248

!

interface GigabitEthernet 0/2

!

...

!

interface GigabitEthernet 0/23

!

interface GigabitEthernet 0/24

no switchport

no ip proxy-arp

ip address 192.168.16.2 255.255.255.248

!

interface Loopback 0

ip address 6.6.6.6 255.255.255.255

ip address 192.168.165.1 255.255.255.0 secondary

ip address 192.168.166.1 255.255.255.0 secondary

!

!

!

!

!

!

!

!

router bgp 23

neighbor 2.2.2.2 remote-as 23

neighbor 2.2.2.2 update-source Loopback 0

neighbor 192.168.16.1 remote-as 1

!

address-family ipv4

network 192.168.165.0

network 192.168.166.0

neighbor 2.2.2.2 activate

neighbor 2.2.2.2 next-hop-self

neighbor 192.168.16.1 activate

exit-address-family

!

!

router ospf 1

router-id 6.6.6.6

network 6.6.6.6 0.0.0.0 area 0

network 192.168.26.0 0.0.0.7 area 0

!

!

!

ip route 192.168.161.0 255.255.255.0 Loopback 0

ip route 192.168.162.0 255.255.255.0 Loopback 0

!

!

line con 0

line vty 0 10

privilege level 15

login

password w

!

!

end

3. 1.2.3检验配置效果

C2

使用show ip bgp可以看到125.0/126.0是源发路由,

111.0/112.0/165.0/166.0是IBGP路由,131.0/132.0是EBGP路由。

使用show ip ospf database可以看到,OSPF中没有外部路由。

C2#show ip bgp

BGP table version is 25, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path

*>i192.168.111.0 6.6.6.6 0 100 0 1 ?

*>i192.168.112.0 6.6.6.6 0 100 0 1 ?

*> 192.168.125.0 0.0.0.0 0 32768 i

*> 192.168.126.0 0.0.0.0 0 32768 i

*> 192.168.131.0 192.168.23.2 0 0 3 ?

*> 192.168.132.0 192.168.23.2 0 0 3 ?

*>i192.168.165.0 6.6.6.6 0 100 0 i

*>i192.168.166.0 6.6.6.6 0 100 0 i

C2#show ip ospf data

OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

2.2.2.2 2.2.2.2 91 0x80000009 0x00B640 2

6.6.6.6 6.6.6.6 498 0x80000004 0x00CD20 2

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.26.2 2.2.2.2 91 0x80000003 0x00C1CF

C2#

R1

使用show ip bgp可以看到165.0/166.0是源发路由,

125.0/126.0/131.0/132.0是IBGP路由,111.0/112.0是EBGP路由。

使用show ip ospf database可以看到,OSPF中没有外部路由。

R1#show ip bgp

BGP table version is 9, local router ID is 192.168.166.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Path

*> 192.168.111.0 192.168.16.1 0 1 ?

*> 192.168.112.0 192.168.16.1 0 1 ?

*>i192.168.125.0 2.2.2.2 0 100 i

*>i192.168.126.0 2.2.2.2 0 100 i

*>i192.168.131.0 2.2.2.2 0 100 3 ?

*>i192.168.132.0 2.2.2.2 0 100 3 ?

*> 192.168.165.0 0.0.0.0 0 i

*> 192.168.166.0 0.0.0.0 0 i

Total number of prefixes 8

R1#show ip ospf data

OSPF Router with ID (6.6.6.6) (Process ID 1)

Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count

2.2.2.2 2.2.2.2 254 0x80000009 0xb640 2

6.6.6.6 6.6.6.6 659 0x80000004 0xcd20 2

Network Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum

192.168.26.2 2.2.2.2 253 0x80000003 0xc1cf

4. 1.2.4重分发BGP的直连路由

C2

配置OSPF重分发BGP路由:

router ospf 1

redistribute bgp 23 subnets

使用show ip ospf database可以看到EBGP路由(131.0/132.0)和直连路

由(125.0/126.0)都重分发给OSPF,而IBGP路由没有重分发给OSPF。

因此可以看出Cisco会向下通告BGP的直连路由(这里是通过network

命令配置的路由)。

C2#sho ip ospf database

OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

2.2.2.2 2.2.2.2 14 0x8000000A 0x00BA39 2

6.6.6.6 6.6.6.6 931 0x80000004 0x00CD20 2

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.26.2 2.2.2.2 524 0x80000003 0x00C1CF

Type-5 AS External Link States

Link ID ADV Router Age Seq# Checksum Tag

192.168.125.0 2.2.2.2 13 0x80000001 0x00D6ED 0

192.168.126.0 2.2.2.2 13 0x80000001 0x00CBF7 0

192.168.131.0 2.2.2.2 13 0x80000001 0x00CAF0 3

192.168.132.0 2.2.2.2 13 0x80000001 0x00BFFA 3

R1

配置OSPF重分发BGP路由:

router ospf 1

redistribute bgp subnets

使用show ip ospf database可以看到IBGP路由

(125.0/126.0/131.0/132.0)和EBGP路由(111.0/112.0)都重分发给OSPF

的,而这里没有直连路由(165.0/166.0)。因为现在的实现中,BGP的

直连路由是不下发的,因此重分发BGP路由的时候BGP的直连路由

是不会被重分发的。

R1#sho ip ospf database

OSPF Router with ID (6.6.6.6) (Process ID 1)

Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count

2.2.2.2 2.2.2.2 781 0x80000011 0xa648 2

6.6.6.6 6.6.6.6 9 0x80000014 0xb328 2

Network Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum

192.168.26.2 2.2.2.2 1544 0x80000008 0xb7d4

AS External Link States

Link ID ADV Router Age Seq# CkSum Route Tag

192.168.111.0 6.6.6.6 8 0x80000001 0xbc24 E2 192.168.111.0/24 0

192.168.112.0 6.6.6.6 8 0x80000001 0xb12e E2 192.168.112.0/24 0

192.168.125.0 6.6.6.6 8 0x80000001 0x22b0 E2 192.168.125.0/24 0

192.168.126.0 6.6.6.6 8 0x80000001 0x17ba E2 192.168.126.0/24 0

192.168.131.0 6.6.6.6 8 0x80000001 0xdfec E2 192.168.131.0/24 0

192.168.132.0 6.6.6.6 8 0x80000001 0xd4f6 E2 192.168.132.0/24 0

因此需要重分发BGP的直连路由,就必须手工的在OSPF中配置BGP

的直连路由。比如:

router ospf 1

network 192.168.165.0 0.0.0.255 area 0

network 192.168.166.0 0.0.0.255 area 0

5. 1.2.5重分发IBGP路由

C2

配置OSPF重分发BGP路由:

router ospf 1

redistribute bgp 23 subnets

使用show ip ospf database可以看到IBGP路由(111.0/112.0/165.0/166.0)

是不会重分发给OSPF,而EBGP路由(131.0/132.0)和源发路由

(125.0/126.0)会重分发给OSPF。因此可以看出Cisco默认缺省是不重

分发IBGP路由的,其它的EBGP路由和源发路由是可以被重分发的。

C2#sho ip ospf database

OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

2.2.2.2 2.2.2.2 14 0x80000010 0x00AE3F 2

6.6.6.6 6.6.6.6 215 0x8000000F 0x00C2DE 4

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.26.2 2.2.2.2 538 0x80000008 0x00B7D4

Type-5 AS External Link States

Link ID ADV Router Age Seq# Checksum Tag

192.168.125.0 2.2.2.2 13 0x80000001 0x00D6ED 0

192.168.126.0 2.2.2.2 13 0x80000001 0x00CBF7 0

192.168.131.0 2.2.2.2 13 0x80000001 0x00CAF0 3

192.168.132.0 2.2.2.2 13 0x80000001 0x00BFFA 3

Cisco可以在BGP模式下使用bgp redistribute-internal命令允许IBGP

路由重分发给IGP协议:

router bgp 23

bgp redistribute-internal

此时使用show ip ospf database可以看到,IBGP路由被重分发到OSPF

中:

C2#sho ip ospf database

OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

2.2.2.2 2.2.2.2 146 0x80000010 0x00AE3F 2

6.6.6.6 6.6.6.6 348 0x8000000F 0x00C2DE 4

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.26.2 2.2.2.2 671 0x80000008 0x00B7D4

Type-5 AS External Link States

Link ID ADV Router Age Seq# Checksum Tag

192.168.111.0 2.2.2.2 4 0x80000001 0x00834E 1

192.168.112.0 2.2.2.2 4 0x80000001 0x007858 1

192.168.125.0 2.2.2.2 145 0x80000001 0x00D6ED 0

192.168.126.0 2.2.2.2 145 0x80000001 0x00CBF7 0

192.168.131.0 2.2.2.2 145 0x80000001 0x00CAF0 3

192.168.132.0 2.2.2.2 145 0x80000001 0x00BFFA 3

192.168.165.0 2.2.2.2 4 0x80000001 0x001D7F 0

192.168.166.0 2.2.2.2 5 0x80000001 0x001289 0

R1

配置OSPF重分发BGP路由:

router ospf 1

redistribute bgp subnets

使用show ip ospf database可以看到IBGP路由

(125.0/126.0/131.0/132.0)和EBGP路由(111.0/112.0)都重分发给OSPF

的(这里没有源发路由)。这就是与Cisco不一致的地方:Cisco缺省不

重分发IBGP路由,而Ruijie是重分发所有BGP路由的。

R1#sho ip ospf database

OSPF Router with ID (6.6.6.6) (Process ID 1)

Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count

2.2.2.2 2.2.2.2 354 0x80000011 0xa648 2

6.6.6.6 6.6.6.6 8 0x80000012 0xb726 2

Network Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum

192.168.26.2 2.2.2.2 1117 0x80000008 0xb7d4

AS External Link States

Link ID ADV Router Age Seq# CkSum Route Tag 192.168.111.0 6.6.6.6 7 0x80000001 0xbc24 E2 192.168.111.0/24 0 192.168.112.0 6.6.6.6 7 0x80000001 0xb12e E2 192.168.112.0/24 0 192.168.125.0 6.6.6.6 7 0x80000001 0x22b0 E2 192.168.125.0/24 0 192.168.126.0 6.6.6.6 7 0x80000001 0x17ba E2 192.168.126.0/24 0 192.168.131.0 6.6.6.6 7 0x80000001 0xdfec E2 192.168.131.0/24 0 192.168.132.0 6.6.6.6 7 0x80000001 0xd4f6 E2 192.168.132.0/24 0 R1#

如果要实现和Cisco缺省行为的一致,可以在OSPF重分发BGP路由

的时候使用route-map,在route-map中应用match route-type规则:router ospf 1

redistribute bgp subnets route-map ospf_redist

route-map ospf_redist

match route-type external

这样使用show ip ospf database就可以看到IBGP路由

(125.0/126.0/131.0/132.0)就不会重分发给OSPF了。

R1#sho ip ospf database

OSPF Router with ID (6.6.6.6) (Process ID 1)

Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count

2.2.2.2 2.2.2.2 602 0x80000011 0xa648 2

6.6.6.6 6.6.6.6 257 0x80000012 0xb726 2

Network Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum

192.168.26.2 2.2.2.2 1365 0x80000008 0xb7d4

AS External Link States

Link ID ADV Router Age Seq# CkSum Route Tag

192.168.111.0 6.6.6.6 256 0x80000001 0xbc24 E2 192.168.111.0/24 0 192.168.112.0 6.6.6.6 256 0x80000001 0xb12e E2 192.168.112.0/24 0

相关主题