20-静态路由典型配置举例
本章节下载: 20-静态路由典型配置举例 (200.09 KB)
目 录
本章介绍了静态路由的各种典型配置。
表1 配置适用的产品与软件版本关系
产品 |
软件版本 |
S10500系列以太网交换机 |
Release 1120系列,Release 1130系列,Release 1200系列 |
S5800&S5820X系列以太网交换机 |
Release 1808 |
S5830系列以太网交换机 |
Release 1115,Release 1118 |
S5500-EI&S5500-SI系列以太网交换机 |
Release 2220 |
如图1所示的简单组网环境中,通过配置静态路由功能实现各主机的路由互通。
(1) 配置交换机各VLAN虚接口的IP地址
# 配置Switch A的VLAN虚接口地址。
<SwitchA> system-view
[SwitchA] vlan 300
[SwitchA-Vlan300] interface Vlan-interface300
[SwitchA-Vlan-interface300] ip address 1.1.2.3 255.255.255.0
[SwitchA-Vlan-interface300] quit
[SwitchA] vlan 500
[SwitchA-Vlan500] interface Vlan-interface500
[SwitchA-Vlan-interface500] ip address 1.1.4.1 255.255.255.252
[SwitchA-Vlan-interface500] quit
# 配置Switch B的VLAN虚接口地址。
<SwitchB> system-view
[SwitchB] vlan 100
[SwitchB-Vlan100] interface Vlan-interface100
[SwitchB-Vlan-interface100] ip address 1.1.6.1 255.255.255.0
[SwitchB-Vlan-interface100] quit
[SwitchB] vlan 500
[SwitchB-Vlan500] interface Vlan-interface500
[SwitchB-Vlan-interface500] ip address 1.1.4.2 255.255.255.252
[SwitchB-Vlan-interface500] quit
[SwitchB] vlan 600
[SwitchB-Vlan600] interface Vlan-interface600
[SwitchB-Vlan-interface600] ip address 1.1.5.5 255.255.255.252
[SwitchB-Vlan-interface600] quit
# 配置Switch C的VLAN虚接口地址。
<SwitchC> system-view
[SwitchC] vlan 600
[SwitchC-Vlan600] interface Vlan-interface600
[SwitchC-Vlan-interface600] ip address 1.1.5.6 255.255.255.252
[SwitchC-Vlan-interface600] quit
[SwitchC] vlan 900
[SwitchC-Vlan900] interface Vlan-interface900
[SwitchC-Vlan-interface900] ip address 1.1.3.1 255.255.255.0
[SwitchC-Vlan-interface900] quit
(2) 配置静态路由
# 在Switch A上配置缺省路由。
<SwitchA> system-view
[SwitchA] ip route-static 0.0.0.0 0.0.0.0 1.1.4.2
# 在Switch B上配置两条静态路由。
<SwitchB> system-view
[SwitchB] ip route-static 1.1.2.0 255.255.255.0 1.1.4.1
[SwitchB] ip route-static 1.1.3.0 255.255.255.0 1.1.5.6
# 在Switch C上配置缺省路由。
<SwitchC> system-view
[SwitchC] ip route-static 0.0.0.0 0.0.0.0 1.1.5.5
(3) 配置主机
配置Host A的缺省网关为1.1.2.3,Host B的缺省网关为1.1.6.1,Host C的缺省网关为1.1.3.1,具体配置过程略。
配置完成后,各主机间能够ping通。
· Switch A
#
vlan 300
#
vlan 500
#
interface Vlan-interface300
ip address 1.1.2.3 255.255.255.0
#
interface Vlan-interface500
ip address 1.1.4.1 255.255.255.252
#
ip route-static 0.0.0.0 0.0.0.0 1.1.4.2
#
· Switch B
#
vlan 100
#
vlan 500
#
vlan 600
#
interface Vlan-interface100
ip address 1.1.6.1 255.255.255.0
#
interface Vlan-interface500
ip address 1.1.4.2 255.255.255.252
#
interface Vlan-interface600
ip address 1.1.5.5 255.255.255.252
#
ip route-static 1.1.2.0 255.255.255.0 1.1.4.1
ip route-static 1.1.3.0 255.255.255.0 1.1.5.6
#
· Switch C
#
vlan 600
#
vlan 900
#
interface Vlan-interface600
ip address 1.1.5.6 255.255.255.252
#
interface Vlan-interface900
ip address 1.1.3.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 1.1.5.5
#
表2 配置适用的产品与软件版本关系
产品 |
软件版本 |
S10500系列以太网交换机 |
Release 1120系列,Release 1130系列,Release 1200系列 |
S5800&S5820X系列以太网交换机 |
Release 1808 |
S5830系列以太网交换机 |
Release 1115,Release 1118 |
S5500-EI&S5500-SI系列以太网交换机 |
Release 2220 |
如图2所示,Switch A和Switch D分别连接了20.1.1.0/24和30.1.1.0/24两个网段,在交换机上配置静态路由以实现两个网段的互通,并通过配置静态路由、Track与NQA联动实现备份路由的快速切换以提高网络的可靠性。
图2 静态路由、Track与NQA联动配置组网图
· 配置NQA测试组通过ICMP-echo测试连通性时,必须要指定路由下一跳,以明确测试的路由路径。
· NQA测试启动后不能再进入测试组视图进行修改,如果要进行修改请通过undo nqa schedule命令手动停止测试。
(1) 按照1.3.2 图2配置各接口的IP地址,具体配置过程略。
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.1.1.2,优先级为缺省值60,该路由与Track项1关联。
<SwitchA> system-view
[SwitchA] ip route-static 30.1.1.0 24 10.1.1.2 track 1
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.3.1.3,优先级为80。
[SwitchA] ip route-static 30.1.1.0 24 10.3.1.3 preference 80
# 配置到达10.2.1.4的静态路由:下一跳地址为10.1.1.2。
[SwitchA] ip route-static 10.2.1.4 24 10.1.1.2
# 创建管理员名为admin、操作标签为test的NQA测试组。
[SwitchA] nqa entry admin test
# 配置测试类型为ICMP-echo。
[SwitchA-nqa-admin-test] type icmp-echo
# 配置测试的目的地址为10.2.1.4,下一跳地址为10.1.1.2,以便通过NQA检测Switch A-Switch B-Switch D这条路径的连通性。
[SwitchA-nqa-admin-test-icmp-echo] destination ip 10.2.1.4
[SwitchA-nqa-admin-test-icmp-echo] next-hop 10.1.1.2
# 配置测试频率为100ms。
[SwitchA-nqa-admin-test-icmp-echo] frequency 100
# 配置联动项1(连续失败5次触发联动)。
[SwitchA-nqa-admin-test-icmp-echo] reaction 1 checked-element probe-fail threshold-type consecutive 5 action-type trigger-only
[SwitchA-nqa-admin-test-icmp-echo] quit
# 启动探测。
[SwitchA] nqa schedule admin test start-time now lifetime forever
# 配置Track项1,关联NQA测试组(管理员为admin,操作标签为test)的联动项1。
[SwitchA] track 1 nqa entry admin test reaction 1
(3) 配置Switch B
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.2.1.4。
<SwitchB> system-view
[SwitchB] ip route-static 30.1.1.0 24 10.2.1.4
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.1.1.1。
[SwitchB] ip route-static 20.1.1.0 24 10.1.1.1
(4) 配置Switch C
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.4.1.4。
<SwitchC> system-view
[SwitchC] ip route-static 30.1.1.0 24 10.4.1.4
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.3.1.1。
[SwitchC] ip route-static 20.1.1.0 24 10.3.1.1
(5) 配置Switch D
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.2.1.2,优先级为缺省值60,该路由与Track项1关联。
<SwitchD> system-view
[SwitchD] ip route-static 20.1.1.0 24 10.2.1.2 track 1
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.4.1.3,优先级为80。
[SwitchD] ip route-static 20.1.1.0 24 10.4.1.3 preference 80
# 配置到达10.1.1.1的静态路由:下一跳地址为10.2.1.2。
[SwitchD] ip route-static 10.1.1.1 24 10.2.1.2
# 创建管理员名为admin、操作标签为test的NQA测试组。
[SwitchD] nqa entry admin test
# 配置测试类型为ICMP-echo。
[SwitchD-nqa-admin-test] type icmp-echo
# 配置测试的目的地址为10.1.1.1,下一跳地址为10.2.1.2,以便通过NQA检测Switch D-Switch B-Switch A这条路径的连通性。
[SwitchD-nqa-admin-test-icmp-echo] destination ip 10.1.1.1
[SwitchD-nqa-admin-test-icmp-echo] next-hop 10.2.1.2
# 配置测试频率为100ms。
[SwitchD-nqa-admin-test-icmp-echo] frequency 100
# 配置联动项1(连续失败5次触发联动)。
[SwitchD-nqa-admin-test-icmp-echo] reaction 1 checked-element probe-fail threshold-type consecutive 5 action-type trigger-only
[SwitchD-nqa-admin-test-icmp-echo] quit
# 启动探测。
[SwitchD] nqa schedule admin test start-time now lifetime forever
# 配置Track项1,关联NQA测试组(管理员为admin,操作标签为test)的联动项1。
[SwitchD] track 1 nqa entry admin test reaction 1
# 显示Switch A上Track项的信息。
[SwitchA] display track all
Track ID: 1
Status: Positive
Notification delay: Positive 0, Negative 0 (in seconds)
Reference object:
NQA entry: admin test
Reaction: 1
# 显示Switch A的路由表。
[SwitchA] display ip routing-table
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.0/24 Direct 0 0 10.1.1.1 Vlan2
10.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.2.1.0/24 Static 60 0 10.1.1.2 Vlan2
10.3.1.0/24 Direct 0 0 10.3.1.1 Vlan3
10.3.1.1/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 Direct 0 0 20.1.1.1 Vlan6
20.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
30.1.1.0/24 Static 60 0 10.1.1.2 Vlan2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
以上显示信息表示,NQA测试的结果为主路由可达(Track项状态为Positive),Switch A通过Switch B将报文转发到30.1.1.0/24网段。
# 在Switch B上用shutdown命令关闭VLAN接口2。
<SwitchB> system-view
[SwitchB] interface vlan-interface 2
[SwitchB-Vlan-interface2] shutdown
# 显示Switch A上Track项的信息。
[SwitchA] display track all
Track ID: 1
Status: Negative
Notification delay: Positive 0, Negative 0 (in seconds)
Reference object:
NQA entry: admin test
Reaction: 1
# 显示Switch A的路由表。
[SwitchA] display ip routing-table
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.0/24 Direct 0 0 10.1.1.1 Vlan2
10.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.2.1.0/24 Static 60 0 10.1.1.2 Vlan2
10.3.1.0/24 Direct 0 0 10.3.1.1 Vlan3
10.3.1.1/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 Direct 0 0 20.1.1.1 Vlan6
20.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
30.1.1.0/24 Static 80 0 10.3.1.3 Vlan3
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
以上显示信息表示,NQA测试的结果为主路由不可达(Track项状态为Negative),则备份路由生效,Switch A通过Switch C将报文转发到30.1.1.0/24网段。
# 主路由出现故障后,20.1.1.0/24网段内的主机仍然可以与30.1.1.0/24网段内的主机通信。
[SwitchA] ping -a 20.1.1.1 30.1.1.1
PING 30.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 30.1.1.1: bytes=56 Sequence=1 ttl=254 time=2 ms
Reply from 30.1.1.1: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 30.1.1.1: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 30.1.1.1: bytes=56 Sequence=4 ttl=254 time=2 ms
Reply from 30.1.1.1: bytes=56 Sequence=5 ttl=254 time=1 ms
--- 30.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/1/2 ms
# Switch D上的显示信息与Switch A类似。主路由出现故障后,30.1.1.0/24网段内的主机仍然可以与20.1.1.0/24网段内的主机通信。
[SwitchD] ping -a 30.1.1.1 20.1.1.1
PING 20.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 20.1.1.1: bytes=56 Sequence=1 ttl=254 time=2 ms
Reply from 20.1.1.1: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=4 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=5 ttl=254 time=1 ms
--- 20.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/1/2 ms
· Switch A
#
nqa entry admin test
type icmp-echo
destination ip 10.2.1.4
frequency 100
next-hop 10.1.1.2
reaction 1 checked-element probe-fail threshold-type consecutive 5 action-type
trigger-only
#
ip route-static 10.2.1.0 255.255.255.0 10.1.1.2
ip route-static 30.1.1.0 255.255.255.0 10.1.1.2 track 1
ip route-static 30.1.1.0 255.255.255.0 10.3.1.3 preference 80
#
track 1 nqa entry admin test reaction 1
#
nqa schedule admin test start-time now lifetime forever
#
· Switch B
ip route-static 20.1.1.0 255.255.255.0 10.1.1.1
ip route-static 30.1.1.0 255.255.255.0 10.2.1.4
· Switch C
ip route-static 20.1.1.0 255.255.255.0 10.3.1.1
ip route-static 30.1.1.0 255.255.255.0 10.4.1.4
· Switch D
#
nqa entry admin test
type icmp-echo
destination ip 10.1.1.1
frequency 100
next-hop 10.2.1.2
reaction 1 checked-element probe-fail threshold-type consecutive 5 action-type
trigger-only
#
ip route-static 10.1.1.0 255.255.255.0 10.2.1.2
ip route-static 20.1.1.0 255.255.255.0 10.2.1.2 track 1
ip route-static 20.1.1.0 255.255.255.0 10.4.1.3 preference 80
#
track 1 nqa entry admin test reaction 1
#
nqa schedule admin test start-time now lifetime forever
#
表3 配置适用的产品与软件版本关系
产品 |
软件版本 |
S10500系列以太网交换机 |
Release 1120系列,Release 1130系列,Release 1200系列 |
S5800&S5820X系列以太网交换机 |
Release 1808 |
S5830系列以太网交换机 |
Release 1115,Release 1118 |
S5500-EI系列以太网交换机 |
Release 2220 |
如图3所示网络,Switch A和Switch B分别连接了20.1.1.0/24和30.1.1.0/24两个网段,在交换机上配置静态路由以实现两个网段的互通,并通过配置静态路由、Track与BFD联动实现备份路由的快速切换以提高网络的可靠性。
图3 静态路由、Track与BFD联动配置组网图
为了避免对端发送大量的ICMP重定向报文造成网络拥塞,建议不要将BFD echo报文的源IP地址配置为属于该设备任何一个接口所在网段。
(1) 按照1.4.2 图3配置各接口的IP地址,具体配置过程略。
(2) 配置Switch A
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.2.1.2,优先级为缺省值60,该路由与Track项1关联。
<SwitchA> system-view
[SwitchA] ip route-static 30.1.1.0 24 10.2.1.2 track 1
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.3.1.3,优先级为80。
[SwitchA] ip route-static 30.1.1.0 24 10.3.1.3 preference 80
# 配置BFD echo报文的源地址为10.10.10.10。
[SwitchA] bfd echo-source-ip 10.10.10.10
# 创建和BFD会话关联的Track项1,检测Switch A是否可以与静态路由的下一跳Switch B互通。
[SwitchA] track 1 bfd echo interface vlan-interface 2 remote ip 10.2.1.2 local ip 10.2.1.1
(3) 配置Switch B
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.2.1.1,优先级为缺省值60,该路由与Track项1关联。
<SwitchB> system-view
[SwitchB] ip route-static 20.1.1.0 24 10.2.1.1 track 1
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.4.1.3,优先级为80。
[SwitchB] ip route-static 20.1.1.0 24 10.4.1.3 preference 80
# 配置BFD echo报文的源地址为1.1.1.1。
[SwitchB] bfd echo-source-ip 1.1.1.1
# 创建和BFD会话关联的Track项1,检测Switch A是否可以与静态路由的下一跳Switch B互通。
[SwitchB] track 1 bfd echo interface vlan-interface 2 remote ip 10.2.1.1 local ip 10.2.1.2
(4) 配置Switch C
# 配置到达30.1.1.0/24网段的静态路由:下一跳地址为10.4.1.2。
<SwitchC> system-view
[SwitchC] ip route-static 30.1.1.0 24 10.4.1.2
# 配置到达20.1.1.0/24网段的静态路由:下一跳地址为10.3.1.1。
[SwitchC] ip route-static 20.1.1.0 24 10.3.1.1
# 显示Switch A上Track项的信息。
[SwitchA] display track all
Track ID: 1
Status: Positive
Notification delay: Positive 0, Negative 0 (in seconds)
Reference object:
BFD Session:
Packet type: Echo
Interface : Vlan-interface2
Remote IP : 10.2.1.2
Local IP : 10.2.1.1
# 显示Switch A的路由表。
[SwitchA] display ip routing-table
Routing Tables: Public
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost NextHop Interface
10.2.1.0/24 Direct 0 0 10.2.1.1 Vlan2
10.2.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.3.1.0/24 Direct 0 0 10.3.1.1 Vlan3
10.3.1.1/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 Direct 0 0 20.1.1.1 Vlan5
20.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
30.1.1.0/24 Static 60 0 10.2.1.2 Vlan2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
以上显示信息表示,BFD检测的结果为下一跳地址10.2.1.2可达(Track项状态为Positive),主路由生效,Switch A通过Switch B将报文转发到30.1.1.0/24网段。
# 在Switch B上用shutdown命令关闭VLAN接口2。
<SwitchB> system-view
[SwitchB] interface vlan-interface 2
[SwitchB-Vlan-interface2] shutdown
# 显示Switch A上Track项的信息。
[SwitchA] display track all
Track ID: 1
Status: Negative
Notification delay: Positive 0, Negative 0 (in seconds)
Reference object:
BFD Session:
Packet type: Echo
Interface : Vlan-interface2
Remote IP : 10.2.1.2
Local IP : 10.2.1.1
# 显示Switch A的路由表。
[SwitchA] display ip routing-table
Routing Tables: Public
Destinations : 4 Routes : 4
Destination/Mask Proto Pre Cost NextHop Interface
10.2.1.0/24 Direct 0 0 10.2.1.1 Vlan2
10.2.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.3.1.0/24 Direct 0 0 10.3.1.1 Vlan3
10.3.1.1/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 Direct 0 0 20.1.1.1 Vlan5
20.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
30.1.1.0/24 Static 80 0 10.3.1.3 Vlan3
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
以上显示信息表示,BFD检测的结果为下一跳地址10.2.1.2不可达(Track项状态为Negative),备份路由生效,Switch A通过Switch C和Switch B将报文转发到30.1.1.0/24网段。
# 主路由出现故障后,20.1.1.0/24网段内的主机仍然可以与30.1.1.0/24网段内的主机通信。
[SwitchA] ping -a 20.1.1.1 30.1.1.1
PING 30.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 30.1.1.1: bytes=56 Sequence=1 ttl=254 time=2 ms
Reply from 30.1.1.1: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 30.1.1.1: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 30.1.1.1: bytes=56 Sequence=4 ttl=254 time=2 ms
Reply from 30.1.1.1: bytes=56 Sequence=5 ttl=254 time=1 ms
--- 30.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/1/2 ms
# Switch B上的显示信息与Switch A类似。主路由出现故障后,30.1.1.0/24网段内的主机仍然可以与20.1.1.0/24网段内的主机通信。
[SwitchB] ping -a 30.1.1.1 20.1.1.1
PING 20.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 20.1.1.1: bytes=56 Sequence=1 ttl=254 time=2 ms
Reply from 20.1.1.1: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=4 ttl=254 time=1 ms
Reply from 20.1.1.1: bytes=56 Sequence=5 ttl=254 time=1 ms
--- 20.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/1/2 ms
· Switch A
#
bfd echo-source-ip 10.10.10.10
#
ip route-static 30.1.1.0 24 10.2.1.2 track 1
ip route-static 30.1.1.0 24 10.3.1.3 preference 80
#
track 1 bfd echo interface vlan-interface 2 remote ip 10.2.1.2 local ip 10.2.1.1
#
· Switch B
#
bfd echo-source-ip 1.1.1.1
#
ip route-static 30.1.1.0 24 10.2.1.2 track 1
ip route-static 20.1.1.0 24 10.4.1.3 preference 80
#
track 1 bfd echo interface vlan-interface 2 remote ip 10.2.1.1 local ip 10.2.1.2
#
· Switch C
#
ip route-static 20.1.1.0 24 10.3.1.1
ip route-static 30.1.1.0 24 10.4.1.2
#
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!