配置BGP团体示例

学习精彩网络技术老师:华为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发布。

图1 配置BGP团体组网图

本例中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号。

操作步骤
  1. 配置各接口的IP地址(略)
  2. 配置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的路由。

  1. 配置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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

精彩网络技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值