配置BGP引入IPv4 ARP Vlink直连路由示例
通过发布IPv4 ARP Vlink直连路由,可以使远端设备获得VLAN内的明细路由,从而实现对流量的精确控制。
组网需求
随着网络的发展,VLAN技术被广泛应用。而VLAN内通常包含多个用户,如果需要与VLAN内的用户通信,一般只需将VLAN所在的网段路由发布出去即可。但是在有些特殊情况下,VLAN外部用户需要知道VLAN内的IPv4 ARP Vlink直连路由,并且针对不同的VLAN用户采取不同的流量控制策略,这时只发布网段路由将无法满足要求。
配置发布IPv4 ARP Vlink直连路由功能即可解决这个问题。如图2-11所示,DeviceC通过VLANIF接口连接了两个用户,出于业务的需要,DeviceD只需要与DeviceB互访,而与DeviceA没有互访需求。这时就可以在DeviceC上配置发布IPv4 ARP Vlink直连路由,并且利用路由策略过滤掉网段路由和到DeviceA的路由即可。
配置思路
采用如下思路配置BGP引入IPv4 ARP Vlink直连路由功能:
在SwitchA和DeviceC上创建VLANIF,并且配置IP地址,保证DeviceA、DeviceB、SwitchA和DeviceC之间的互通。
- 在DeviceC和DeviceD之间配置BGP协议,保证DeviceC和DeviceD之间可以相互传递路由。
在DeviceC上配置发布IPv4 ARP Vlink直连路由,使IPv4 ARP Vlink直连路由可发布。
在DeviceC上配置路由策略,只允许来源于DeviceB的路由通过。
在DeviceC上配置BGP引入直连路由,并且应用路由策略只引入来源于DeviceB的路由。
在DeviceC上配置BGP使用路由出口过滤策略,过滤掉VLAN所在网段路由,使DeviceD无法看到网段路由,只能使用ARP Vlink直连路由与VLAN内的用户通信,这样便于控制VLAN内用户与VLAN外的通信。
数据准备
为完成此配置例,需准备如下的数据:
SwitchA和DeviceC所在的VLAN ID为10。
DeviceC和DeviceD的Router ID分别为3.3.3.3和4.4.4.4,所在AS号都为100。
过滤直连路由所使用的路由策略为policy1。
DeviceC上发布BGP路由所使用的路由策略为policy2。
操作步骤
- 配置各接口的IP地址
# 配置DeviceA。
<HUAWEI> system-view
[~HUAWEI] sysname DeviceA
[*HUAWEI] commit
[~DeviceA] interface GigabitEthernet 0/1/0
[*DeviceA-GigabitEthernet0/1/0] undo shutdown
[*DeviceA-GigabitEthernet0/1/0] ip address 10.1.1.3 24
[*DeviceA-GigabitEthernet0/1/0] commit
[~DeviceA-GigabitEthernet0/1/0] quit
# 配置DeviceB。
<HUAWEI> system-view
[~HUAWEI] sysname DeviceB
[*HUAWEI] commit
[~DeviceB] interface GigabitEthernet 0/1/0
[*DeviceB-GigabitEthernet0/1/0] undo shutdown
[*DeviceB-GigabitEthernet0/1/0] ip address 10.1.1.4 24
[*DeviceB-GigabitEthernet0/1/0] commit
[~DeviceB-GigabitEthernet0/1/0] quit
# 配置DeviceC。
<HUAWEI> system-view
[~HUAWEI] sysname DeviceC
[*HUAWEI] commit
[~DeviceC] interface GigabitEthernet 0/2/0
[*DeviceC-GigabitEthernet0/2/0] undo shutdown
[*DeviceC-GigabitEthernet0/2/0] ip address 10.2.1.1 24
[*DeviceC-GigabitEthernet0/2/0] commit
[~DeviceC-GigabitEthernet0/2/0] quit
# 配置DeviceD。
<HUAWEI> system-view
[~HUAWEI] sysname DeviceD
[*HUAWEI] commit
[~DeviceD] interface GigabitEthernet 0/1/0
[*DeviceD-GigabitEthernet0/1/0] undo shutdown
[*DeviceD-GigabitEthernet0/1/0] ip address 10.2.1.2 24
[*DeviceD-GigabitEthernet0/1/0] commit
[~DeviceD-GigabitEthernet0/1/0] quit
- 配置VLAN基本功能。在SwitchA和DeviceC分别创建VLANIF10,并且配置IP地址
# 配置SwitchA。
<HUAWEI> system-view
[~HUAWEI] sysname SwitchA
[*HUAWEI] commit
[~SwitchA] vlan 10
[*SwitchA-vlan10] quit
[*SwitchA] interface GigabitEthernet 0/1/0
[*SwitchA-GigabitEthernet0/1/0] portswitch
[*SwitchA-GigabitEthernet0/1/0] undo shutdown
[*SwitchA-GigabitEthernet0/1/0] port link-type access
[*SwitchA-GigabitEthernet0/1/0] port default vlan 10
[*SwitchA-GigabitEthernet0/1/0] quit
[*SwitchA] interface GigabitEthernet 0/2/0
[*SwitchA-GigabitEthernet0/2/0] portswitch
[*SwitchA-GigabitEthernet0/2/0] undo shutdown
[*SwitchA-GigabitEthernet0/2/0] port link-type access
[*SwitchA-GigabitEthernet0/2/0] port default vlan 10
[*SwitchA-GigabitEthernet0/2/0] quit
[*SwitchA] interface GigabitEthernet 0/3/0
[*SwitchA-GigabitEthernet0/3/0] portswitch
[*SwitchA-GigabitEthernet0/3/0] undo shutdown
[*SwitchA-GigabitEthernet0/3/0] port link-type access
[*SwitchA-GigabitEthernet0/3/0] port default vlan 10
[*SwitchA-GigabitEthernet0/3/0] quit
[*SwitchA] interface Vlanif 10
[*SwitchA-Vlanif10] ip address 10.1.1.2 24
[*SwitchA-Vlanif10] commit
[~SwitchA-Vlanif10] quit
# 配置DeviceC。
[~DeviceC] vlan 10
[*DeviceC-vlan10] quit
[*DeviceC] interface GigabitEthernet 0/1/0
[*DeviceC-GigabitEthernet0/1/0] portswitch
[*DeviceC-GigabitEthernet0/1/0] undo shutdown
[*DeviceC-GigabitEthernet0/1/0] port link-type access
[*DeviceC-GigabitEthernet0/1/0] port default vlan 10
[*DeviceC-GigabitEthernet0/1/0] quit
[*DeviceC] interface Vlanif 10
[*DeviceC-Vlanif10] ip address 10.1.1.1 24
[*DeviceC-Vlanif10] commit
[~DeviceC-Vlanif10] quit
- 在DeviceC和DeviceD之间配置BGP协议
# 配置DeviceC。
[~DeviceC] bgp 100
[*DeviceC-bgp] router-id 3.3.3.3
[*DeviceC-bgp] peer 10.2.1.2 as-number 100
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
# 配置DeviceD。
[~DeviceD] bgp 100
[*DeviceD-bgp] router-id 4.4.4.4
[*DeviceD-bgp] peer 10.2.1.1 as-number 100
[*DeviceD-bgp] commit
[~DeviceD-bgp] quit
- 在DeviceC上配置BGP引入直连路由,并且查看DeviceC和DeviceD的BGP路由表
# 配置DeviceC。
[~DeviceC] bgp 100
[~DeviceC-bgp] import-route direct
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
# 查看DeviceC的BGP路由表。
[~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: 9 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.1.1.0/24 0.0.0.0 0 0 ? *> 10.1.1.1/32 0.0.0.0 0 0 ? *> 10.1.1.2/32 0.0.0.0 0 0 ? *> 10.2.1.0/24 0.0.0.0 0 0 ? *> 10.2.1.1/32 0.0.0.0 0 0 ? *> 127.0.0.0 0.0.0.0 0 0 ? *> 127.0.0.1/32 0.0.0.0 0 0 ?
# 查看DeviceD的BGP路由表。
[~DeviceD] display bgp routing-table
BGP Local router ID is 4.4.4.4 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: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 10.1.1.0/24 10.2.1.1 0 100 0 ? i 10.2.1.0/24 10.2.1.1 0 100 0 ?
可以看到DeviceD没有学到10.1.1.3/32和10.1.1.4/32这两条ARP Vlink直连路由。
- 在DeviceC配置使能IPv4 ARP Vlink直连路由发布,并且配置路由策略policy1过滤掉网段路由和10.1.1.3/32这条来自DeviceA的路由
# 配置DeviceC。
[~DeviceC] ip ip-prefix prefix1 permit 10.1.1.4 32
[*DeviceC] route-policy policy1 permit node 10
[*DeviceC-route-policy] if-match ip-prefix prefix1
[*DeviceC-route-policy] quit
[*DeviceC] arp vlink-direct-route advertise route-policy policy1
[*DeviceC] commit
# 查看DeviceC的BGP路由表。
[~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: 9 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.1.1.0/24 0.0.0.0 0 0 ? *> 10.1.1.1/32 0.0.0.0 0 0 ? *> 10.1.1.2/32 0.0.0.0 0 0 ? *> 10.1.1.3/32 0.0.0.0 0 0 ? *> 10.1.1.4/32 0.0.0.0 0 0 ? *> 10.2.1.0/24 0.0.0.0 0 0 ? *> 10.2.1.1/32 0.0.0.0 0 0 ? *> 127.0.0.0 0.0.0.0 0 0 ? *> 127.0.0.1/32 0.0.0.0 0 0 ?
# 查看DeviceD的BGP路由表。
[~DeviceD] display bgp routing-table
BGP Local router ID is 4.4.4.4 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: 3 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 10.1.1.0/24 10.2.1.1 0 100 0 ? *>i 10.1.1.4/32 10.2.1.1 0 100 0 ? i 10.2.1.0/24 10.2.1.1 0 100 0 ?
可以看到DeviceD已经学到10.1.1.4/32这条IPv4 ARP Vlink直连路由,而10.1.1.3/32这条路由被过滤掉了。
- 在DeviceC上配置BGP发布路由时使用policy2过滤掉网段路由10.1.1.0/24
# 配置DeviceC。
[~DeviceC] ip ip-prefix prefix2 index 10 deny 10.1.1.0 24
[*DeviceC] ip ip-prefix prefix2 index 20 permit 0.0.0.0 0 less-equal 32
[*DeviceC] route-policy policy2 permit node 10
[*DeviceC-route-policy] if-match ip-prefix prefix2
[*DeviceC-route-policy] quit
[*DeviceC] bgp 100
[*DeviceC-bgp] peer 10.2.1.2 route-policy policy2 export
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
[~DeviceC] quit
<DeviceC> refresh bgp all export
# 查看DeviceD的BGP路由表。
[~DeviceD] display bgp routing-table
BGP Local router ID is 4.4.4.4 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: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 10.1.1.4/32 10.2.1.1 0 100 0 ? i 10.2.1.0/24 10.2.1.1 0 100 0 ?
可以看到DeviceD的BGP路由表中10.1.1.0/24这条路由消失。这样DeviceD将只能与DeviceB通信,而无法与DeviceA通信。
配置文件
SwitchA的配置文件
# sysname switchA # vlan batch 10 # interface Vlanif10 ip address 10.1.1.2 255.255.255.0 # interface GigabitEthernet0/1/0 portswitch undo shutdown port link-type access port default vlan 10 # interface GigabitEthernet0/2/0 portswitch undo shutdown port link-type access port default vlan 10 # interface GigabitEthernet0/3/0 portswitch undo shutdown port link-type access port default vlan 10 # return
DeviceA的配置文件
# sysname DeviceA # interface GigabitEthernet0/1/0 undo shutdown ip address 10.1.1.3 255.255.255.0 # return
DeviceB的配置文件
# sysname DeviceB # interface GigabitEthernet0/1/0 undo shutdown ip address 10.1.1.4 255.255.255.0 # return
DeviceC的配置文件
# sysname DeviceC # arp vlink-direct-route advertise route-policy policy1 # vlan batch 10 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 # interface GigabitEthernet0/1/0 portswitch undo shutdown port link-type access port default vlan 10 # interface GigabitEthernet0/2/0 undo shutdown ip address 10.2.1.1 255.255.255.0 # bgp 100 router-id 3.3.3.3 peer 10.2.1.2 as-number 100 # ipv4-family unicast undo synchronization import-route direct peer 10.2.1.2 enable peer 10.2.1.2 route-policy policy2 export # route-policy policy1 permit node 10 if-match ip-prefix prefix1 # route-policy policy2 permit node 10 if-match ip-prefix prefix2 # ip ip-prefix prefix1 index 10 permit 10.1.1.4 32 ip ip-prefix prefix2 index 10 deny 10.1.1.0 24 ip ip-prefix prefix2 index 20 permit 0.0.0.0 0 less-equal 32 # return
DeviceD的配置文件
# sysname DeviceD # interface GigabitEthernet0/1/0 undo shutdown ip address 10.2.1.2 255.255.255.0 # # bgp 100 router-id 4.4.4.4 peer 10.2.1.1 as-number 100 # ipv4-family unicast undo synchronization peer 10.2.1.1 enable # return