通过将指定的策略路由与BFD会话绑定,可以实现根据网络状况动态调整策略路由的目的。
组网需求
如图1所示,某公司有两个部门A和B。因两个部门A和B均为业务部门,业务流量大,需要不同链路分担流量。且网络稳定性要求高,要求网络不中断。
为满足部门A和部门B的需求,公司申请了两条接入Internet的链路ISP1和ISP2来分担链路流量,并互为备份,以保证链路持续不中断。
详细需求如下:
· 部门A所在网段为10.1.0.0/16,该部门访问Internet的报文正常情况下流入链路ISP1。
· 部门B所在网段为20.1.0.0/16,该部门访问Internet的报文正常情况下流入链路ISP2。
· 部门A和部门B所在链路互为备份,并利用BFD监测链路的故障,当某部门的链路(以下称主链路)出现故障时,流量切换到另一部门所在的链路(以下称备链路)上。
图1 配置策略路由和BFD联动组网图
项目 |
数据 |
备注 |
|
USG |
(1) |
接口号:GigabitEthernet 0/0/1 IP地址:10.1.0.1/16 安全区域:Trust |
GigabitEthernet 0/0/1接口连接部门A所在的10.1.0.0/16网段。 |
(2) |
接口号:GigabitEthernet 0/0/2 IP地址:20.1.0.1/16 安全区域:Trust |
GigabitEthernet 0/0/2接口连接部门B所在的20.1.0.0/16网段。 |
|
(3) |
接口号:GigabitEthernet 0/0/3 IP地址:1.1.2.2/24 安全区域:Untrust |
GigabitEthernet 0/0/3接入Internet的链路ISP1。 |
|
(4) |
接口号:GigabitEthernet 0/0/4 IP地址:1.1.3.2/24 安全区域:natzone |
GigabitEthernet 0/0/4接入Internet的链路ISP2。 |
|
Router_A |
IP地址:1.1.2.1/24 |
为来自部门A的报文流向ISP1链路所指定的下一跳。 |
|
Router_B |
IP地址:1.1.3.1/24 |
为来自部门B的报文流向ISP2链路所指定的下一跳。 |
配置思路
说明:
本例仅介绍策略路由相关的配置,USG为各部门提供上网服务所必须的NAT、Router_A和Router_B到USG间的路由可达等相关配置,不在此介绍。
策略路由和BFD联动配置思路如下:
1. 为实现不同链路分担不同流量,需要配置基于源地址的策略路由,使来自部门A的访问Internet报文流向链路ISP1,来自部门B的访问Internet报文流向链路ISP2。
2. 为实现部门A和部门B所在链路互为备份,保证链路不中断,需要配置如下:
a. 在USG、Router_A和Router_B上配置静态BFD会话,分别检测USG与Router_A和Router_B之间的链路连通性。
b. 配置策略路由和BFD联动,由BFD来监视部门A和部门B各自主链路的可达性。当主链路出现故障时,策略路由失效,设备将查找备份路由,以保持业务的持续流通。
c. 配置部门A到链路ISP2的静态路由和部门B到链路ISP1的静态路由,作为部门A和部门B的备份路由。同时,将静态路由与BFD联动,由BFD来监视部门A和部门B各自备链路的可达性。
操作步骤
1. 配置USG。
a. 配置USG的接口IP地址。具体步骤略。
b. 通过定义ACL,以确定要进行策略路由转发的报文。
说明:
为实现部门A和部门B的互相访问,需要配置高级ACL,对某部门所发起的目的地址为另一部门的报文不依据策略路由进行转发。如果部门A和部门B没有互相访问的需求,可以配置基本ACL。有关ACL的详细介绍,请参见配置ACL。
# 定义ACL 3001,允许通过源地址为10.1.0.0/16的报文,拒绝目的地址为20.1.0.0/16的报文。
<USG> system-view
[USG] acl number 3001
[USG-acl-adv-3001] rule deny ip destination 20.1.0.0 0.0.255.255
[USG-acl-adv-3001] rule permit ip source 10.1.0.0 0.0.255.255
[USG-acl-adv-3001] quit
# 定义ACL 3002,允许通过源地址为20.1.0.0/16的报文,拒绝目的地址为10.1.0.0/16的报文。
[USG] acl number 3002
[USG-acl-adv-3002] rule deny ip destination 10.1.0.0 0.0.255.255
[USG-acl-adv-3002] rule permit ip source 20.1.0.0 0.0.255.255
[USG-acl-adv-3002] quit
c. 配置静态BFD会话。
# 配置BFD会话1,对端IP地址为1.1.2.1,本地标识符为10,远端标识符为20。
[USG] bfd
[USG-bfd] quit
[USG] bfd 1 bind peer-ip 1.1.2.1
[USG-bfd-session-1] discriminator local 10
[USG-bfd-session-1] discriminator remote 20
[USG-bfd-session-1] commit
[USG-bfd-session-1] quit
# 配置BFD会话2,对端IP地址为1.1.3.1,本地标识符为30,远端标识符为40。
[USG] bfd 2 bind peer-ip 1.1.3.1
[USG-bfd-session-2] discriminator local 30
[USG-bfd-session-2] discriminator remote 40
[USG-bfd-session-2] commit
[USG-bfd-session-2] quit
d. 配置策略路由,并与BFD会话关联。
# 配置策略testA,使源地址为10.1.0.0/16的报文被发到下一跳1.1.2.1,并与BFD会话1关联。
[USG] policy-based-route testA permit node 5
[USG-policy-based-route-testA-5] if-match acl 3001
[USG-policy-based-route-testA-5] apply ip-address next-hop 1.1.2.1 track bfd-session 10
[USG-policy-based-route-testA-5] quit
# 配置策略testB,使源地址为20.1.0.0/16的报文被发到下一跳1.1.3.1,并与BFD会话2关联。
[USG] policy-based-route testB permit node 5
[USG-policy-based-route-testB-5] if-match acl 3002
[USG-policy-based-route-testB-5] apply ip-address next-hop 1.1.3.1 track bfd-session 30
[USG-policy-based-route-testB-5] quit
# 在接口GigabitEthernet 0/0/1上应用定义的策略testA,处理此接口接收的报文。
[USG] interface GigabitEthernet 0/0/1
[USG-GigabitEthernet0/0/1] ip policy-based-route testA
[USG-GigabitEthernet0/0/1] quit
# 在接口GigabitEthernet 0/0/2上应用定义的策略testB,处理此接口接收的报文。
[USG] interface GigabitEthernet 0/0/2
[USG-GigabitEthernet0/0/2] ip policy-based-route testB
[USG-GigabitEthernet0/0/2] quit
e. 配置缺省路由,并与BFD关联。
# 配置缺省路由,指定下一跳1.1.2.1/24,并与BFD会话1关联。
[USG] ip route-static 0.0.0.0 0.0.0.0 1.1.2.1 track bfd-session 1
# 配置缺省路由,指定下一跳1.1.3.1/24,并与BFD会话2关联。
[USG] ip route-static 0.0.0.0 0.0.0.0 1.1.3.1 track bfd-session 2
f. 对于USG系列,将接口加入安全区域,并配置域间包过滤,以保证网络基本通信正常,具体步骤略。对于USG BSR/HSR系列,不需要将接口加入安全区域以及配置包过滤。
说明:
· 由于BFD侦测报文是由设备自身所发,为实现BFD功能,需要在USG上打开发送BFD侦测报文的接口GigabitEthernet 0/0/3和GigabitEthernet 0/0/4所在安全区域和Local域之间的包过滤,允许报文在域间通过。
· 如果部门A和部门B的用户需要访问USG,需要在USG上打开连接部门A和部门B的接口所在安全区域和Local域之间的包过滤,允许报文在域间通过。
2. 在配置Router_A上创建BFD会话1。
# 配置BFD会话1,对端IP地址为1.1.2.2,本地标识符为20,远端标识符为10。
<Router_A> system-view
[Router_A] bfd
[Router_A-bfd] quit
[Router_A] bfd 1 bind peer-ip 1.1.2.2
[Router_A-bfd-session-1] discriminator local 20
[Router_A-bfd-session-1] discriminator remote 10
[Router_A-bfd-session-1] commit
[Router_A-bfd-session-1] quit
3. 在配置Router_B上创建BFD会话2。
# 配置BFD会话2,对端IP地址为1.1.3.2,本地标识符为40,远端标识符为30。
<Router_B> system-view
[Router_B] bfd
[Router_B-bfd] quit
[Router_B] bfd 2 bind peer-ip 1.1.3.2
[Router_B-bfd-session-1] discriminator local 40
[Router_B-bfd-session-1] discriminator remote 30
[Router_B-bfd-session-1] commit
[Router_B-bfd-session-1] quit
结果验证
1. 在主链路均可达的情况下,来自部门A的访问Internet报文经USG转发后应全部流入链路ISP1,来自部门B的访问Internet报文经USG转发后应全部流入链路ISP2。
# 执行命令display bfd session all,应查看到BFD会话已经建立,且状态均为Up。
[USG] display bfd session all
--------------------------------------------------------------------------------
Local Remote Peer IP Address Interface Name State Type
--------------------------------------------------------------------------------
10 20 1.1.2.1 -- Up Static
30 40 1.1.3.1 -- Up Static
--------------------------------------------------------------------------------
# 部门A的用户ping 1.1.2.1,结果应成功,而ping 1.1.3.1,结果应失败。
C:\Documents and Settings\DepartA>ping 1.1.2.1
Pinging 1.1.2.1 with 32 bytes of data:
Reply from 1.1.2.1: bytes=32 time=9ms TTL=254
Reply from 1.1.2.1: bytes=32 time=2ms TTL=254
Reply from 1.1.2.1: bytes=32 time=2ms TTL=254
Reply from 1.1.2.1: bytes=32 time=5ms TTL=254
Ping statistics for 1.1.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 9ms, Average = 4ms
C:\Documents and Settings\DepartA>ping 1.1.3.1
Pinging 1.1.3.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 1.1.3.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
# 部门B的用户ping 1.1.3.1,结果应成功,而ping 1.1.2.1,结果应失败。
C:\Documents and Settings\DepartB>ping 1.1.3.1
Pinging 1.1.3.1 with 32 bytes of data:
Reply from 1.1.3.1: bytes=32 time=2ms TTL=254
Reply from 1.1.3.1: bytes=32 time=1ms TTL=254
Reply from 1.1.3.1: bytes=32 time=1ms TTL=254
Reply from 1.1.3.1: bytes=32 time=2ms TTL=254
Ping statistics for 1.1.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Documents and Settings\DepartB>ping 1.1.2.1
Pinging 1.1.2.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 1.1.2.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
2. 在主链路出现故障的情况下,USG应为各部门查找备份路由,将报文转发到备链路上。以部门A的主链路ISP1出现故障时为例进行说明。
# 执行命令display bfd session all,应查看到部门A所在链路的BFD会话1的状态为Down。
[USG] display bfd session all
--------------------------------------------------------------------------------
Local Remote Peer IP Address Interface Name State Type
--------------------------------------------------------------------------------
10 20 1.1.2.1 -- Down Static
30 40 1.1.3.1 -- Up Static
--------------------------------------------------------------------------------
# 部门A的用户ping 1.1.2.1,结果应失败,而ping 1.1.3.1,结果应成功。
C:\Documents and Settings\DepartA>ping 1.1.3.1
Pinging 1.1.3.1 with 32 bytes of data:
Reply from 1.1.3.1: bytes=32 time=2ms TTL=254
Reply from 1.1.3.1: bytes=32 time=1ms TTL=254
Reply from 1.1.3.1: bytes=32 time=1ms TTL=254
Reply from 1.1.3.1: bytes=32 time=2ms TTL=254
Ping statistics for 1.1.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Documents and Settings\DepartA>ping 1.1.2.1
Pinging 1.1.2.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 1.1.2.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
3. 在主链路恢复正常的情况下,USG应将报文全部转发到主链路上。以部门A的主链路ISP1恢复正常时为例进行说明。
# 执行命令display bfd session all,应查看到部门A所在链路的BFD会话的状态为Up。
[USG] display bfd session all
--------------------------------------------------------------------------------
Local Remote Peer IP Address Interface Name State Type
--------------------------------------------------------------------------------
10 20 1.1.2.1 -- Up Static
30 40 1.1.3.1 -- Up Static
--------------------------------------------------------------------------------
# 部门A的用户ping 1.1.2.1,结果应成功,而ping 1.1.3.1,结果应失败。
C:\Documents and Settings\DepartA>ping 1.1.2.1
Pinging 1.1.2.1 with 32 bytes of data:
Reply from 1.1.2.1: bytes=32 time=2ms TTL=254
Reply from 1.1.2.1: bytes=32 time=1ms TTL=254
Reply from 1.1.2.1: bytes=32 time=1ms TTL=254
Reply from 1.1.2.1: bytes=32 time=2ms TTL=254
Ping statistics for 1.1.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Documents and Settings\DepartA>ping 1.1.3.1
Pinging 1.1.3.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 1.1.3.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
4. 部门A和部门B应能互相访问。以部门A的用户ping部门B的用户为例进行说明。
5. C:\Documents and Settings\DepartA>ping 20.1.0.111
6.
7. Pinging 20.1.0.111 with 32 bytes of data:
8.
9. Reply from 20.1.0.111: bytes=32 time=2ms TTL=127
10. Reply from 20.1.0.111: bytes=32 time=1ms TTL=127
11. Reply from 20.1.0.111: bytes=32 time=1ms TTL=127
12. Reply from 20.1.0.111: bytes=32 time=2ms TTL=127
13.
14. Ping statistics for 20.1.0.111:
15. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
16. Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
配置脚本
· USG的配置脚本
· #
· sysname USG
· #
· firewall packet-filter default permit interzone local untrust direction inbound
· firewall packet-filter default permit interzone local untrust direction outbound
· firewall packet-filter default permit interzone local trust direction inbound
· firewall packet-filter default permit interzone local trust direction outbound
· firewall packet-filter default permit interzone local natzone direction inbound
· firewall packet-filter default permit interzone local natzone direction outbound
· #
· bfd
· #
· acl number 3001
· rule 5 deny ip destination 20.1.0.0 0.0.255.255
· rule 10 permit ip source 10.1.0.0 0.0.255.255
· acl number 3002
· rule 5 deny ip destination 10.1.0.0 0.0.255.255
· rule 10 permit ip source 20.1.0.0 0.0.255.255
· #
· interface GigabitEthernet0/0/1
· ip address 10.1.0.1 255.255.0.0
· ip policy-based-route testA
· #
· interface GigabitEthernet0/0/2
· ip address 20.1.0.1 255.255.0.0
· ip policy-based-route testB
· #
· interface GigabitEthernet0/0/3
· ip address 1.1.2.2 255.255.255.0
· #
· interface GigabitEthernet0/0/4
· ip address 1.1.3.2 255.255.255.0
· #
· firewall zone trust
· set priority 85
· add interface GigabitEthernet0/0/1
· add interface GigabitEthernet0/0/2
· firewall zone natzone
· set priority 10
· add interface GigabitEthernet0/0/4
· firewall zone untrust
· set priority 5
· add interface GigabitEthernet0/0/3
· #
· bfd 1 bind peer-ip 1.1.2.1
· discriminator local 10
· discriminator remote 20
· commit
· #
· bfd 2 bind peer-ip 1.1.3.1
· discriminator local 30
· discriminator remote 40
· commit
· #
· ip route-static 0.0.0.0 0.0.0.0 1.1.2.1 track bfd-session 1
· ip route-static 0.0.0.0 0.0.0.0 1.1.3.1 track bfd-session 2
· #
· policy-based-route testA permit node 5
· if-match acl 3001
· apply ip-address next-hop 1.1.2.1 track bfd-session 10
· policy-based-route testB permit node 5
· if-match acl 3002
· apply ip-address next-hop 1.1.3.1 track bfd-session 30
· #
return
· Router_A的配置脚本
· #
· sysname Router_A
· #
· bfd
· #
· bfd 1 bind peer-ip 1.1.2.2
· discriminator local 20
· discriminator remote 10
· commit
· #
return
· Router_B的配置脚本
· #
· sysname Router_B
· #
· bfd
· #
· bfd 2 bind peer-ip 1.1.3.2
·&nbs
京公网安备11010602022021 京ICP备11016550号-7号 24小时客服QQ 504927 客服微信 504927
Copyright © 2010-2025 北京世博云创科技有限公司 《中华人民共和国增值电信业务经营许可证 B1-20161178》
想了解更多的我们
关注我们的微信吧!