目录
静态路由
路由信息
- 目标网段
- 目标网段掩码
- 出接口
- 下一跳地址
用来标识目的网段,为转发IP报文指路。
路由表
路由器中路由条目的集合 路由器会根据路由表的路径做出选择
获取方式
-
直连路由
-
静态路由:手工配置、单向
-
动态路由:OSPF协议
TIPs
最长匹配原则:采用二叉树进行检索。
主机路由匹配32位,默认路由匹配0位。
静态路由协议只能小规模的企业网络,大型企业网络用的是动态路由协议。
ENSP查看IP路由表
display ip routing-table
静态路由的配置
常规代码
ip route-static 目标ip网络地址 子网掩码 下一跳
默认路由
ip route-static 0.0.0.0 0.0.0.0 下一跳
注意事项
- 各路由转发的方向
- 查看需要配置总共有几条路由路径
- 每个路由器的非直连路由有几条
1、配置路由信息,以实现pc1和pc2可以通讯
拓扑图
1、配置PC1和PC2的网络信息
2、配置路由器
配置AR1
…… int g0/0/0 ip add 10.1.1.1 24 int g0/0/1 ip add 11.1.1.1 24 quit ip route-static 20.1.1.0 24 11.1.1.2
配置AR2
…… int g0/0/0 ip add 11.1.1.2 24 int g0/0/1 ip add 12.1.1.1 24 quit ip route-static 20.1.1.0 24 12.1.1.2 ip route-static 10.1.1.0 24 11.1.1.1
配置AR3
…… int g0/0/0 ip add 12.1.1.2 24 int g0/0/1 ip add 20.1.1.1 24 quit ip route-static 10.1.1.0 24 12.1.1.1
测试
2、使拓扑图上的所有设备通信
拓扑图
1、配置终端设备的网络信息
2、配置交换机
s1
[s1]vlan batch 10 20 [s1]int e0/0/1 [s1-Ethernet0/0/1]p l a [s1-Ethernet0/0/1]p d v 10 [s1-Ethernet0/0/1]int e0/0/2 [s1-Ethernet0/0/2]p l a [s1-Ethernet0/0/2]p d v 10 [s1-Ethernet0/0/2]int e0/0/3 [s1-Ethernet0/0/3]p l t [s1-Ethernet0/0/3]p t a v 10 20 [s1]vlan 30 [s1]int e0/0/3 [s1-Ethernet0/0/3]p t a v 30
s2
[s2]vlan batch 10 20 Info: This operation may take a few seconds. Please wait for a moment...done. [s2]int e0/0/1 [s2-Ethernet0/0/1]ip add [s2-Ethernet0/0/1]p l a [s2-Ethernet0/0/1]p d v 20 [s2-Ethernet0/0/1]int e0/0/8 [s2-Ethernet0/0/8]int e0/0/2 [s2-Ethernet0/0/2]p l a [s2-Ethernet0/0/2]p d v 20 [s2-Ethernet0/0/2]int e0/0/3 [s2-Ethernet0/0/3]p l t [s2-Ethernet0/0/3]p t a v 10 20 [s2] vlan 30 [s2]int e0/0/3 [s2-Ethernet0/0/3]p t a v 30
s3
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys s3 [s3]vlan bat [s3]vlan batch 10 20 Info: This operation may take a few seconds. Please wait for a moment...done. [s3]int g0/0/3 [s3-GigabitEthernet0/0/3]p l t [s3-GigabitEthernet0/0/3]p t a v 10 20 [s3-GigabitEthernet0/0/3]int vlanif 10 [s3-Vlanif10]ip address 10.1.1.1 24 [s3-Vlanif10]q [s3]int g0/0/2 [s3-GigabitEthernet0/0/2]vlan batch 10 20 Info: This operation may take a few seconds. Please wait for a moment...done. [s3-GigabitEthernet0/0/2]p l t [s3-GigabitEthernet0/0/2]p t a v 10 20 [s3-GigabitEthernet0/0/2]int vlanif 20 [s3-Vlanif20]ip ad [s3-Vlanif20]ip address 20.1.1.1 24 [s3-Vlanif20] [s3-Vlanif20] [s3-Vlanif20]q [s3]vlan 30 [s3-vlan30]q [s3]int g0/0/1 [s3-GigabitEthernet0/0/1]p l a [s3-GigabitEthernet0/0/1]p d v 30 [s3-GigabitEthernet0/0/1]int vlanif 30 [s3-Vlanif30]q [s3]int g0/0/2 [s3-GigabitEthernet0/0/2]p t a v 30 [s3-GigabitEthernet0/0/2]int g0/0/3 [s3-GigabitEthernet0/0/3]p t a v 30 [s3-GigabitEthernet0/0/3]int g0/0/1 [s3-GigabitEthernet0/0/1]q [s3]ip route-static 50.1.1.0 24 30.1.1.1
3、配置路由器
[a1]int g0/0/1 [a1-GigabitEthernet0/0/1]ip address 30.1.1.11 24 [a1-GigabitEthernet0/0/1]int g0/0/0 [a1-GigabitEthernet0/0/0]ip address 50.1.1.11 24 [a1-GigabitEthernet0/0/0]q [a1]ip route-static 0.0.0.0 0 30.1.1.10
测试
sever1 ping pc1
3、使拓扑图上的server和终端设备通信
配置二层交换机
s1
[s1]vlan batch 10 20 30 40 50 60 [s1]int e0/0/2 [s1-Ethernet0/0/2]p l a [s1-Ethernet0/0/2]p d v 10 [s1-Ethernet0/0/2]int e0/0/3 [s1-Ethernet0/0/3]p l a [s1-Ethernet0/0/3]p d v 20 [s1-Ethernet0/0/3]int e0/0/1 [s1-Ethernet0/0/1]p l t [s1-Ethernet0/0/1]p t a v all
s2
[s2]vlan batch 10 20 30 40 50 60 Info: This operation may take a few seconds. Please wait for a moment...done. [s2]int e0/0/2 [s2-Ethernet0/0/2]p l a [s2-Ethernet0/0/2]p d v 30 [s2-Ethernet0/0/2]int e0/0/3 [s2-Ethernet0/0/3]p l a [s2-Ethernet0/0/3]p d v 40 [s2-Ethernet0/0/3]int e0/0/1 [s2-Ethernet0/0/1]p l t [s2-Ethernet0/0/1]p t a v all
配置三层交换机
配置三层交换机s3
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys s3 [s3]vlan ba [s3]vlan batch 10 20 30 40 50 60 Info: This operation may take a few seconds. Please wait for a moment...done. [s3]int g0/0/2 [s3-GigabitEthernet0/0/2]p l t [s3-GigabitEthernet0/0/2]p t a v all [s3-GigabitEthernet0/0/2]q [s3]int vlanif 50 [s3-Vlanif50]ip address 50.1.1.50 24 [s3-Vlanif50]int g0/0/1 [s3-GigabitEthernet0/0/1]p l a [s3-GigabitEthernet0/0/1]p d v 50 [s3-GigabitEthernet0/0/1]q [s3]ip route-static 70.1.1.0 24 50.1.1.1 [s3]int vlanif 10 [s3-Vlanif10]ip [s3-Vlanif10]ip add 10.1.1.1 24 [s3-Vlanif10]int vlanif 20 [s3-Vlanif20]ip add 20.1.1.1 24
配置三层交换机s4
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys s4 [s4]vlan batch 10 20 30 40 50 60 Info: This operation may take a few seconds. Please wait for a moment...done. [s4]int g0/0/2 [s4-GigabitEthernet0/0/2]p l t [s4-GigabitEthernet0/0/2]p t a v all [s4-GigabitEthernet0/0/2]int g0/0/1 [s4-GigabitEthernet0/0/1]p l a [s4-GigabitEthernet0/0/1]p d v 60 [s4-GigabitEthernet0/0/1]q [s4]int vlanif 60 [s4-Vlanif60]ip add [s4-Vlanif60]ip address 60.1.1.60 24 [s4-Vlanif60]q [s4]int vlanif 30 [s4-Vlanif30]ip address 30.1.1.1 24 [s4-Vlanif30]int vlanif 40 [s4-Vlanif40]ip address 40.1.1.1 24 [s4-Vlanif40]q [s4]ip route-static 70.1.1.0 24 60.1.1.1
配置路由器AR1
配置路由器接口ip
[a1-GigabitEthernet0/0/0]ip add 70.1.1.1 24 [a1-GigabitEthernet0/0/1]ip add 50.1.1.1 24 [a1-GigabitEthernet0/0/2]ip add 60.1.1.1 24
配置路由器路由表
ip route-static 10.1.1.0 255.255.255.0 50.1.1.50 ip route-static 20.1.1.0 255.255.255.0 50.1.1.50 ip route-static 30.1.1.0 255.255.255.0 60.1.1.60 ip route-static 40.1.1.0 255.255.255.0 60.1.1.60
测试
server1 ping pc1、pc2、pc3、pc4