学习精彩网络技术老师:华为HCIA和HCIP数通eNSP实战视频课
学习精彩网络技术老师:华为HCIA和HCIP数通eNSP实战视频课、华三、锐捷、WLAN、IPv6等全套视频课程
利用团体属性,可以灵活控制BGP的路由选择。
组网需求
企业A、企业B和企业C分属于三个AS,其中企业B的网络与其他两个企业通过EBGP相连接,实现相互通信。由于企业A和企业C之间属于竞争关系,企业A为了提高安全性希望自己所在AS发送给企业B的路由只在企业B内传播,而不传播给企业C。为了解决此问题,可在企业A往企业B发送路由的设备上配置团体属性功能。
如图1所示,DeviceB分别与DeviceA、DeviceC之间建立EBGP连接。如果用户希望DeviceA引入的路由发布到AS20的DeviceB后,只在AS20内传播而不发送给其他AS,则可以通过在DeviceA上配置No_Export团体属性,使AS10发布到AS20中的BGP路由,不再被AS20向其他AS发布。
本例中interface1,interface2,interface3分别代表GE0/1/0,GE0/2/0,GE0/3/0。
配置思路
采用如下的思路配置BGP团体:
DeviceA和DeviceB之间,DeviceB和DeviceC之间分别配置EBGP连接。
在DeviceA上配置路由策略,发布No_Export团体属性。
数据准备
为完成此配置例,需准备如下的数据:
DeviceA的Router ID和所在AS号。
DeviceB的Router ID和所在AS号。
DeviceC的Router ID和所在AS号。
操作步骤
- 配置各接口的IP地址(略)
- 配置EBGP
# 配置DeviceA。
[~DeviceA] bgp 10
[*DeviceA-bgp] router-id 1.1.1.1
[*DeviceA-bgp] peer 10.1.2.2 as-number 20
[*DeviceA-bgp] ipv4-family unicast
[*DeviceA-bgp-af-ipv4] network 10.5.1.0 255.255.255.0
[*DeviceA-bgp-af-ipv4] commit
[~DeviceA-bgp-af-ipv4] quit
# 配置DeviceB。
[~DeviceB] bgp 20
[*DeviceB-bgp] router-id 2.2.2.2
[*DeviceB-bgp] peer 10.1.2.1 as-number 10
[*DeviceB-bgp] peer 10.1.3.2 as-number 30
[*DeviceB-bgp] commit
[~DeviceB-bgp] quit
# 配置DeviceC。
[~DeviceC] bgp 30
[*DeviceC-bgp] router-id 3.3.3.3
[*DeviceC-bgp] peer 10.1.3.1 as-number 20
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
# 查看DeviceB的路由表。
[~DeviceB] display bgp routing-table 10.5.1.0
BGP local router ID : 2.2.2.2
Local AS number : 20
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.5.1.0/24:
From: 10.1.2.1 (1.1.1.1)
Route Duration: 0d00h00m37s
Direct Out-interface: GigabitEthernet0/2/0
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 10, origin igp, MED 0, pref-val 0, valid, external, best, select, pre 255
Advertised to such 2 peers:
10.1.2.1
10.1.3.2
可以看出,DeviceB把收到的路由发布给了位于AS30内的DeviceC。
# 查看DeviceC的路由表。
[~DeviceC] display bgp routing-table
BGP Local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - damped, x - best external, a - add path,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V - valid, I - invalid, N - not-found
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.5.1.0/24 10.1.3.1 0 20 10i
从路由表可以确认,DeviceC从DeviceB那里学到了目的地址为10.5.1.0/24的路由。
- 配置BGP团体属性
# 在DeviceA上配置路由策略,使得DeviceA发布给DeviceB的路由,不再被DeviceB发布给其他AS。
[~DeviceA] route-policy comm_policy permit node 10
[*DeviceA-route-policy] apply community no-export
[*DeviceA-route-policy] commit
[~DeviceA-route-policy] quit
# 应用路由策略。
[~DeviceA] bgp 10
[*DeviceA-bgp] ipv4-family unicast
[*DeviceA-bgp-af-ipv4] peer 10.1.2.2 route-policy comm_policy export
[*DeviceA-bgp-af-ipv4] peer 10.1.2.2 advertise-community
[*DeviceA-bgp-af-ipv4] commit
# 查看DeviceB的路由表。
[~DeviceB] display bgp routing-table 10.5.1.0
BGP local router ID : 2.2.2.2
Local AS number : 20
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.5.1.0/24:
From: 10.1.2.1 (1.1.1.1)
Route Duration: 0d00h00m12s
Direct Out-interface: GigabitEthernet0/2/0
Original nexthop: 10.1.2.1
Qos information : 0x0
Community:no-export
AS-path 10, origin igp, MED 0, pref-val 0, valid, external, best, select, pre 255
Not advertised to any peers yet
在DeviceB的BGP路由表中可以看到配置的团体属性。此时在DeviceC的BGP路由表中已经没有到目的地址10.5.1.0/24的路由。
配置文件
DeviceA的配置文件
#
sysname DeviceA
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 10.5.1.1 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 10.1.2.1 255.255.255.0
#
bgp 10
router-id 1.1.1.1
peer 10.1.2.2 as-number 20
#
ipv4-family unicast
undo synchronization
network 10.5.1.0 255.255.255.0
peer 10.1.2.2 enable
peer 10.1.2.2 route-policy comm_policy export
peer 10.1.2.2 advertise-community
#
route-policy comm_policy permit node 10
apply community no-export
#
return
DeviceB的配置文件
#
sysname DeviceB
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 10.1.2.2 255.255.255.0
#
interface GigabitEthernet0/3/0
undo shutdown
ip address 10.1.3.1 255.255.255.0
#
bgp 20
router-id 2.2.2.2
peer 10.1.2.1 as-number 10
peer 10.1.3.2 as-number 30
#
ipv4-family unicast
undo synchronization
peer 10.1.2.1 enable
peer 10.1.3.2 enable
#
return
DeviceC的配置文件
#
sysname DeviceC
#
interface GigabitEthernet0/3/0
undo shutdown
ip address 10.1.3.2 255.255.255.0
#
bgp 30
router-id 3.3.3.3
peer 10.1.3.1 as-number 20
#
ipv4-family unicast
undo synchronization
peer 10.1.3.1 enable
#
return