01-H3C_BGP基础配置举例
本章节下载: 01-H3C_BGP基础配置举例 (238.08 KB)
H3C BGP基础典型配置举例
资料版本:6W100-20200330
产品版本:Release 7585P05
Copyright © 2020 新华三技术有限公司 版权所有,保留一切权利。
非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。
除新华三技术有限公司的商标外,本手册中出现的其它公司的商标、产品标识及商品名称,由各自权利人拥有。
本文档中的信息可能变动,恕不另行通知。
目? 录
本文档介绍了BGP的基础典型配置举例。
本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。
本文档假设您已了解BGP特性。
随着A公司的不断发展,其网络规模也不断扩大,导致其设备运行的IGP协议不堪重负,为了解决这一问题,公司管理者决定在设备上运行一些BGP的基础配置。如图1所示,所有交换机均运行BGP协议。要求Switch A和Switch B之间建立EBGP连接,Switch B和Switch C之间建立IBGP连接,使得Switch C能够访问Switch A直连的8.1.1.0/24网段。
图1 IPv4 BGP基础配置组网图
· 在AS 65009内部,保证Switch B到Switch C的LoopBack接口路由可达,Switch C到Switch B的LoopBack接口路由可达,这样两个IBGP对等体才能建立TCP连接,本案例使用OSPF协议实现。
· 由于设备缺省情况下BGP不发布任何本地的网段路由,为了使Switch C能够访问Switch A直连的8.1.1.0/24网段,将8.1.1.0/24网段宣告进Switch A的BGP进程中,将3.1.1.0/24网段和9.1.1.0/24网段宣告进Switch B的BGP进程中。
· 为了防止端口状态不稳定引起路由震荡,本举例使用LoopBack接口来创建IBGP对等体。
· 使用LoopBack接口创建IBGP对等体时,因为LoopBack接口不是两对等体实际连接的接口,所以,必须使用peer connect-interface命令将LoopBack接口配置为BGP连接的源接口。
· EBGP邻居关系的两台路由器,处于不同的AS域,对端的LoopBack接口一般路由不可达,所以一般使用直连地址建立EBGP邻居。
# 配置接口Vlan-int100的IP地址。
<SwitchA> system-view
[SwitchA] interface Vlan-interface 100
[SwitchA-Vlan-interface100] ip address 8.1.1.1 24
#请参考以上方法配置其它相关接口的IP地址,配置步骤这里省略。
[SwitchB] bgp 65009
[SwitchB-bgp-default-default] router-id 2.2.2.2
[SwitchB-bgp-default-default] peer 3.3.3.3 as-number 65009
[SwitchB-bgp-default-default] peer 3.3.3.3 connect-interface Loopback 0
[SwitchB-bgp-default-default] address-family ipv4 unicast
[SwitchB-bgp-default-default-ipv4] peer 3.3.3.3 enable
[SwitchB-bgp-default-default-ipv4] quit
[SwitchB-bgp-default-default] quit
[SwitchB] ospf 1
[SwitchB-ospf-1] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 2.2.2.2 0.0.0.0
[SwitchB-ospf-1-area-0.0.0.0] network 9.1.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] quit
[SwitchB-ospf-1] quit
[SwitchC] bgp 65009
[SwitchC-bgp-default-default] router-id 3.3.3.3
[SwitchC-bgp-default] peer 2.2.2.2 as-number 65009
[SwitchC-bgp-default] peer 2.2.2.2 connect-interface Loopback 0
[SwitchC-bgp-default] address-family ipv4 unicast
[SwitchC-bgp-default-ipv4] peer 2.2.2.2 enable
[SwitchC-bgp-default-ipv4] quit
[SwitchC-bgp-default] quit
[SwitchC] ospf 1
[SwitchC-ospf-1] area 0
[SwitchC-ospf-1-area-0.0.0.0] network 3.3.3.3 0.0.0.0
[SwitchC-ospf-1-area-0.0.0.0] network 9.1.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] quit
[SwitchC-ospf-1] quit
# 查看Switch C的BGP对等体的连接状态。
[SwitchC] display bgp peer ipv4
?BGP local router ID : 3.3.3.3
?Local AS number : 65009
?Total number of peers : 1???????????????? Peers in established state : 1
? Peer??????????????????? AS? MsgRcvd ?MsgSent OutQ PrefRcv Up/Down? State
? 2.2.2.2????????????? 65009??????? 2??????? 2??? 0?????? 0 00:00:13 Established
以上显示信息表明Switch B和Switch C之间的IBGP连接已经建立。
[SwitchA] bgp 65008
[SwitchA-bgp-default] router-id 1.1.1.1
[SwitchA-bgp-default] peer 3.1.1.1 as-number 65009
[SwitchA-bgp-default] address-family ipv4 unicast
[SwitchA-bgp-default-ipv4] peer 3.1.1.1 enable
[SwitchA-bgp-default-ipv4] network 8.1.1.0 24
[SwitchA-bgp-default-ipv4] quit
[SwitchA-bgp-default] quit
[SwitchB-bgp-default] peer 3.1.1.2 as-number 65008
[SwitchB-bgp-default] address-family ipv4 unicast
[SwitchB-bgp-default-ipv4] peer 3.1.1.2 enable
[SwitchB-bgp-default-ipv4] quit
[SwitchB-bgp-default] quit
# 查看Switch B的BGP对等体的连接状态。
[SwitchB] display bgp peer ipv4
?BGP local router ID : 2.2.2.2
?Local AS number : 65009
?Total number of peers : 2???????????????? Peers in established state : 2
? Peer??????????????????? AS? MsgRcvd? MsgSent OutQ PrefRcv Up/Down? State
? 3.3.3.3????????????? 65009??????? 4??????? 4??? 0?????? 0 00:02:49 Established
? 3.1.1.2????????????? 65008??????? 2??????? 2??? 0?????? 0 00:00:05 Established
可以看出,Switch B与Switch C、Switch B与Switch A之间的BGP连接均已建立。
# 查看Switch A的BGP路由表。
[SwitchA] display bgp routing-table ipv4
?Total number of routes: 1
?BGP local router ID is 1.1.1.1
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network??????????? NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
* >? 8.1.1.0/24???????? 8.1.1.1???????? 0???????????????????? 32768?? i
# 查看Switch B的BGP路由表。
[SwitchB] display bgp routing-table ipv4
?Total number of routes: 1
?BGP local router ID is 2.2.2.2
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network??????????? NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
* >e 8.1.1.0/24???????? 3.1.1.2???????? 0???????????????????? 0?????? 65008i
# 查看Switch C的BGP路由表。
[SwitchC] display bgp routing-table ipv4
?Total number of routes: 1
?BGP local router ID is 3.3.3.3
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network??????????? NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
?? i 8.1.1.0/24???????? 3.1.1.2???????? 0????????? 100??????? 0?????? 65008i
从路由表可以看出,Switch A没有学到AS 65009内部的任何路由,Switch C虽然学到了AS 65008中的8.1.1.0的路由,但因为下一跳3.1.1.2不可达,所以也不是有效路由。
在Switch B上配置BGP发布本地网段路由,以便Switch A能够获取到网段9.1.1.0/24的路由,Switch C能够获取到网段3.1.1.0/24的路由。
[SwitchB-bgp-default] address-family ipv4 unicast
[SwitchB-bgp-default-ipv4] network 3.1.1.0 24
[SwitchB-bgp-default-ipv4] network 9.1.1.0 24
[SwitchB-bgp-default-ipv4] quit
[SwitchB-bgp-default] quit
# 查看Switch A的BGP路由表。
[SwitchA] display bgp routing-table ipv4
?Total number of routes: 3
?BGP local router ID is 1.1.1.1
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network??????????? NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
* >e 3.1.1.0/24???????? 3.1.1.1???????? 0???????????????????? 0?????? 65009?
* >? 8.1.1.0/24???????? 8.1.1.1???????? 0???????????????????? 32768?? i
* >e 9.1.1.0/24???????? 3.1.1.1???????? 0???????????????????? 0?????? 65009i
以上显示信息表明,在Switch B上发布本地网段路由后,Switch A新增了到达9.1.1.0/24的路由。
# 查看Switch C的BGP路由表。
[SwitchC] display bgp routing-table ipv4
?Total number of routes: 3
?BGP local router ID is 3.3.3.3
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network??????????? NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
* >i 3.1.1.0/24???????? 2.2.2.2???????? 0????????? 100??????? 0?????? ?
* >i 8.1.1.0/24???????? 3.1.1.2???????? 0????????? 100??????? 0?????? 65008i
* >i 9.1.1.0/24???????? 2.2.2.2???????? 0????????? 100??????? 0?????? i
以上显示信息表明,到8.1.1.0的路由变为有效路由,下一跳为Switch A的地址。
# 在SwitchC上Ping目标地址8.1.1.1进行验证。
Ping 8.1.1.1 (8.1.1.1): 56 data bytes, press CTRL_C to break
56 bytes from 8.1.1.1: icmp_seq=0 ttl=254 time=10.000 ms
56 bytes from 8.1.1.1: icmp_seq=1 ttl=254 time=4.000 ms
56 bytes from 8.1.1.1: icmp_seq=2 ttl=254 time=4.000 ms
56 bytes from 8.1.1.1: icmp_seq=3 ttl=254 time=3.000 ms
56 bytes from 8.1.1.1: icmp_seq=4 ttl=254 time=3.000 ms
--- Ping statistics for 8.1.1.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 3.000/4.800/10.000/2.638 ms
以上信息表明Switch C能够访问Switch A直连的8.1.1.0/24网段。
· Switch A
#
vlan 100
#
vlan 200
#
interface Loopback0
?ip address 1.1.1.1 255.255.255.255
#
interface Vlan-interface100
?ip address 8.1.1.1 255.255.255.0
#
interface Vlan-interface200
?ip address 3.1.1.2 255.255.255.0
#
bgp 65008
?router-id 1.1.1.1
?peer 3.1.1.1 as-number 65009
#
address-family ipv4 unicast
?network 8.1.1.0 255.255.255.0
?peer 3.1.1.1 enable
#
· Switch B
#
vlan 200
#
vlan 300
#
interface Loopback0
?ip address 2.2.2.2 255.255.255.255
#
interface Vlan-interface200
?ip address 3.1.1.1 255.255.255.0
#
interface Vlan-interface300
?ip address 9.1.1.1 255.255.255.0
#
bgp 65009
?router-id 2.2.2.2
?peer 3.1.1.2 as-number 65008
?peer 3.3.3.3 as-number 65009
?peer 3.3.3.3 connect-interface Loopback0
#
address-family ipv4 unicast
?network 3.1.1.0 255.255.255.0
?network 9.1.1.0 255.255.255.0
?peer 3.1.1.2 enable
?peer 3.3.3.3 enable
#
ospf 1
?area 0.0.0.0
??network 2.2.2.2 0.0.0.0
??network 9.1.1.0 0.0.0.255
#
· Switch C
#
vlan 300
#
interface Loopback0
?ip address 3.3.3.3 255.255.255.255
#
interface Vlan-interface300
?ip address 9.1.1.2 255.255.255.0
#
bgp 65009
?router-id 3.3.3.3
?peer 2.2.2.2 as-number 65009
?peer 2.2.2.2 connect-interface Loopback0
#
address-family ipv4 unicast
?peer 2.2.2.2 enable
#
ospf 1
?area 0.0.0.0
??network 3.3.3.3 0.0.0.0
??network 9.1.1.0 0.0.0.255
#
公司A的所有设备在AS 65008内,公司B的所有设备在AS 65009内,AS 65008和AS 65009通过设备Switch A和Switch B相连。公司A的研发部门所在网段为8.1.1.0/24,公司B的研发部门所在网段为9.1.2.0/24。
由于市场需求,现在两个公司决定联合开发一款新型产品,这就需要两个公司的研发部门可以互相通信,实现网段9.1.2.0/24与网段8.1.1.0/24的互通,同时需要确保两个公司的其它网段不能相互通信。
图2 BGP与IGP交互配置组网图
在Switch B上将BGP和OSPF路由互相引入,使得Switch A可以访问9.1.2.0/24网段,Switch C可以访问8.1.1.0/24网段。
EBGP邻居关系的两台路由器,处于不同的AS域,对端的LoopBack接口一般路由不可达,所以一般使用直连地址建立EBGP邻居。
# 配置接口Vlan-int100的IP地址。
<SwitchA> system-view
[SwitchA] interface Vlan-interface 100
[SwitchA-Vlan-interface100] ip address 8.1.1.1 24
# 请参考以上方法配置其它相关接口的IP地址,配置步骤这里省略。
在AS 65009内配置OSPF,使得Switch B能获取到到9.1.2.0/24网段的路由。
[SwitchB] ospf 1
[SwitchB-ospf-1] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 2.2.2.2 0.0.0.0
[SwitchB-ospf-1-area-0.0.0.0] network 9.1.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] quit
[SwitchB-ospf-1] quit
[SwitchC] ospf 1
[SwitchC-ospf-1] area 0
[SwitchC-ospf-1-area-0.0.0.0] network 9.1.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] network 9.1.2.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] quit
[SwitchC-ospf-1] quit
配置EBGP连接,并在Switch A上将8.1.1.0/24网段通告到BGP路由表中,以便Switch B获取到网段8.1.1.0/24的路由。
[SwitchA] bgp 65008
[SwitchA-bgp-default] router-id 1.1.1.1
[SwitchA-bgp-default] peer 3.1.1.1 as-number 65009
[SwitchA-bgp-default] address-family ipv4 unicast
[SwitchA-bgp-default-ipv4] peer 3.1.1.1 enable
[SwitchA-bgp-default-ipv4] network 8.1.1.0 24
[SwitchA-bgp-default-ipv4] quit
[SwitchA-bgp-default] quit
[SwitchB-bgp-default] router-id 2.2.2.2
[SwitchB-bgp-default] peer 3.1.1.2 as-number 65008
[SwitchB-bgp-default] address-family ipv4 unicast
[SwitchB-bgp-default-ipv4] peer 3.1.1.2 enable
# 在Switch B上配置BGP和OSPF互相引入路由。
[SwitchB-bgp-default-ipv4] import-route ospf 1
[SwitchB-bgp-default-ipv4] quit
[SwitchB-bgp-default] quit
[SwitchB] ospf 1
[SwitchB-ospf-1] import-route bgp
[SwitchB-ospf-1] quit
# 查看Switch A的BGP路由表。
[SwitchA] display bgp routing-table ipv4
?Total number of routes: 3
?BGP local router ID is 1.1.1.1
?Status codes: * - valid, > - best, d - dampened, h - history,
?????????????? s - suppressed, S - stale, i - internal, e - external
?????? Origin: i - IGP, e - EGP, ? - incomplete
???? Network?? ?????????NextHop???????? MED??????? LocPrf???? PrefVal Path/Ogn
* >? 8.1.1.0/24???????? 8.1.1.1???????? 0???????????????????? 32768?? i
* >e 9.1.2.0/24???????? 3.1.1.1???????? 1???????????????????? 0?????? 65009?
# 查看Switch C的OSPF路由表。
[SwitchC] display ospf routing
????????? OSPF Process 1 with Router ID 3.3.3.3
?????????????????? Routing Tables
?Routing for Network
?Destination??????? Cost???? Type??? NextHop???????? AdvRouter?????? Area
?9.1.1.0/24???????? 1??????? Transit 9.1.1.2???????? 3.3.3.3??? ?????0.0.0.0
9.1.2.0/24???????? 1??????? Stub??? 9.1.2.1???????? 192.168.0.63? ??0.0.0.0
?2.2.2.2/32???????? 1??????? Stub??? 9.1.1.1???????? 2.2.2.2???????? 0.0.0.0
?Routing for ASEs
?Destination??????? Cost???? Type??? Tag???????? NextHop???????? AdvRouter
?8.1.1.0/24???????? 1??????? Type2?? 1?????????? 9.1.1.1???????? 2.2.2.2
?Total Nets: 3
?Intra Area: 2? Inter Area: 0? ASE: 1? NSSA: 0
从Switch A的BGP路由表和Switch C的OSPF路由表可以看出,Swtich B上的BGP和OSPF路由已经互相引入。
# 在Switch A上使用源地址8.1.1.1Ping目标地址9.1.2.1进行验证。
[SwitchA] ping -a 8.1.1.1 9.1.2.1
Ping 9.1.2.1 (9.1.2.1) from 8.1.1.1: 56 data bytes, press CTRL_C to break
56 bytes from 9.1.2.1: icmp_seq=0 ttl=254 time=10.000 ms
56 bytes from 9.1.2.1: icmp_seq=1 ttl=254 time=12.000 ms
56 bytes from 9.1.2.1: icmp_seq=2 ttl=254 time=2.000 ms
56 bytes from 9.1.2.1: icmp_seq=3 ttl=254 time=7.000 ms
56 bytes from 9.1.2.1: icmp_seq=4 ttl=254 time=9.000 ms
--- Ping statistics for 9.1.2.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 2.000/8.000/12.000/3.406 ms
# 在Switch C上使用源地址9.1.2.1Ping目标地址8.1.1.1进行验证。
[SwitchC] ping -a 9.1.2.1 8.1.1.1
Ping 8.1.1.1 (8.1.1.1) from 9.1.2.1: 56 data bytes, press CTRL_C to break
56 bytes from 8.1.1.1: icmp_seq=0 ttl=254 time=9.000 ms
56 bytes from 8.1.1.1: icmp_seq=1 ttl=254 time=4.000 ms
56 bytes from 8.1.1.1: icmp_seq=2 ttl=254 time=3.000 ms
56 bytes from 8.1.1.1: icmp_seq=3 ttl=254 time=3.000 ms
56 bytes from 8.1.1.1: icmp_seq=4 ttl=254 time=3.000 ms
--- Ping statistics for 8.1.1.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 3.000/4.400/9.000/2.332 ms
上述显示信息说明网段9.1.2.0/24与网段8.1.1.0/24能实现互通。
# 在Switch A上使用源地址8.1.2.1分别Ping目标地址9.1.2.1和9.1.3.1进行验证。
[SwitchA] ping –a 8.1.2.1 9.1.2.1
Ping 9.1.2.1 (9.1.2.1) from 8.1.2.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- Ping statistics for 9.1.2.1 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
[SwitchA] ping –a 8.1.2.1 9.1.3.1
Ping 9.1.3.1 (9.1.3.1) from 8.1.2.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- Ping statistics for 9.1.3.1 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
# 在Switch C上使用源地址9.1.3.1分别Ping目标地址8.1.1.1和8.1.2.1进行验证。
[SwitchC] ping –a 9.1.3.1 8.1.1.1
Ping 8.1.1.1 (8.1.1.1) from 9.1.3.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- Ping statistics for 8.1.1.1 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
[SwitchC] ping –a 9.1.3.1 8.1.2.1
Ping 8.1.2.1 (8.1.2.1) from 9.1.3.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- Ping statistics for 8.1.2.1 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
上述信息说明两个自治区域之间只有网段9.1.2.0/24与网段8.1.1.0/24能实现互通,其他网段之间是无法互通的。
· Switch A
#
vlan 100
#
vlan 200
#
vlan 600
#
interface Loopback0
?ip address 1.1.1.1 255.255.255.255
#
interface Vlan-interface100
?ip address 8.1.1.1 255.255.255.0
#
interface Vlan-interface200
?ip address 3.1.1.2 255.255.255.0
#
interface Vlan-interface600
?ip address 8.1.2.1 255.255.255.0
#
bgp 65008
?router-id 1.1.1.1
?peer 3.1.1.1 as-number 65009
#
address-family ipv4 unicast
?network 8.1.1.0 255.255.255.0
?peer 3.1.1.1 enable
#
· Switch B
#
vlan 200
#
vlan 300
#
vlan 500
#
interface Loopback0
?ip address 2.2.2.2 255.255.255.255
#
interface Vlan-interface200
ip address 3.1.1.1 255.255.255.0
#
interface Vlan-interface300
ip address 9.1.1.1 255.255.255.0
#
bgp 65009
?router-id 2.2.2.2
?peer 3.1.1.2 as-number 65008
#
address-family ipv4 unicast
?import-route ospf 1
?peer 3.1.1.2 enable
#
ospf 1
?import-route bgp
?area 0.0.0.0
??network 2.2.2.2 0.0.0.0
??network 9.1.1.0 0.0.0.255
#
· Switch C
#
vlan 300
#
vlan 400
#
interface Loopback0
?ip address 3.3.3.3 255.255.255.255
#
interface Vlan-interface300
?ip address 9.1.1.2 255.255.255.0
#
interface Vlan-interface400
?ip address 9.1.2.1 255.255.255.0
#
interface Vlan-interface500
ip address 9.1.3.1 255.255.255.0
#
ospf 1
?area 0.0.0.0
??network 9.1.1.0 0.0.0.255
??network 9.1.2.0 0.0.0.255
#
· H3C S7500E-XS系列交换机 三层技术-IP路由配置指导-R758X
· H3C S7500E-XS系列交换机 三层技术-IP路由命令参考-R758X
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!