【汇总】华为路由交换由浅入深系列
掌握目标
拓扑
一、配置设备名称与IP地址:
R1:
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 202.100.1.1 255.255.255.0
quit
[R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]ip add 202.100.2.1 255.255.255.0
quit
[R1-GigabitEthernet0/0/1]int lo 0 =====创建环回接口
[R1-LoopBack0]ip add 1.1.1.1 255.255.255.255
[R1-LoopBack0]quit
[R1]display current-configuration interface =====显示接口信息
#
interface GigabitEthernet0/0/0
#
interface GigabitEthernet0/0/1
ip address 202.100.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 202.100.2.1 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
R2:
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip add 202.100.1.2 255.255.255.0
[R2-GigabitEthernet0/0/1]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 202.100.3.2 255.255.255.0
[R2-GigabitEthernet0/0/0]int lo 0
[R2-LoopBack0]ip ad 2.2.2.2 255.255.255.255
[R2-LoopBack0]quit
R3:
[R3]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 202.100.2.3 255.255.255.0
[R3-GigabitEthernet0/0/2]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 202.100.3.3 255.255.255.0
[R3-GigabitEthernet0/0/0]int lo 0
[R3-LoopBack0]ip add 3.3.3.3 255.255.255.255
ping -c 2 202.100.1.2 =====ping两个数据包
PING 202.100.1.2: 56 data bytes, press CTRL_C to break
Reply from 202.100.1.2: bytes=56 Sequence=1 ttl=255 time=10 ms
Reply from 202.100.1.2: bytes=56 Sequence=2 ttl=255 time=1 ms
— 202.100.1.2 ping statistics —
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/5/10 ms
ping -c 2 202.100.2.3
PING 202.100.2.3: 56 data bytes, press CTRL_C to break
Reply from 202.100.2.3: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 202.100.2.3: bytes=56 Sequence=2 ttl=255 time=10 ms
— 202.100.2.3 ping statistics —
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/15/20 ms
display ip routing-table ====查看路由表
Route Flags: R – relay, D – download to fib
——————————————————————————
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
202.100.1.0/24 Direct 0 0 D 202.100.1.1 GigabitEthernet0
二、配置静态路由
[R1]ip route-static 3.3.3.3 255.255.255.255 202.100.2.3 ===添加静态路由
[R1]ip route-static 202.100.3.0 255.255.255.0 202.100.2.3
[R1]display ip routing-table =====Static代表静态路由,60代表静态路由优先级
Route Flags: R – relay, D – download to fib
——————————————————————————
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.3/32 Static 60 0 RD 202.100.2.3 GigabitEthernet0
ping -c 1 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=10 ms
ping -c 1 202.100.3.3
PING 202.100.3.3: 56 data bytes, press CTRL_C to break
Reply from 202.100.3.3: bytes=56 Sequence=1 ttl=255 time=10 ms
三、配置浮动路由用于备份
配置备份静态路由,当R1与R3之间链路出现故障时,可走R2。
[R2]ip route-static 3.3.3.3 255.255.255.255 202.100.3.3
[R1]ip route-static 202.100.3.0 24 202.100.1.2 preference 80
[R1]ip route-static 3.3.3.3 32 202.100.1.2 preference 80
[R3]ip route-static 202.100.1.0 255.255.255.0 202.100.3.2
[R1]tracert 202.100.3.3
traceroute to 202.100.3.3(202.100.3.3), max hops: 30 ,packet length: 40,press CTRL_C to break
1 202.100.2.3 10 ms 10 ms 20 ms
[R1]tracert 3.3.3.3
traceroute to 3.3.3.3(3.3.3.3), max hops: 30 ,packet length: 40,press CTRL_C to break
1 202.100.2.3 20 ms 10 ms 20 ms
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]shutdown
[R1]display ip routing-table
Route Flags: R – relay, D – download to fib
——————————————————————————
Routing Tables: Public
Destinations : 10 Routes : 10
3.3.3.3/32 Static 80 0 RD 202.100.1.2 GigabitEthernet0/0/1
202.100.3.0/24 Static 80 0 RD 202.100.1.2 GigabitEthernet0/0/1
[R1]tracert 3.3.3.3
1 202.100.1.2 20 ms 1 ms 10 ms
2 202.100.3.3 20 ms 10 ms 20 ms
[R1]tracert 202.100.3.3
1 202.100.1.2 1 ms 10 ms 10 ms
2 202.100.3.3 20 ms 20 ms 20 ms
[R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]undo shutdown (注:华为设备中no掉配置命令undo) 此处敲restart也可以
May 12 2014 22:58:05-05:13 R1 %%01IFPDT/4/IF_STATE(l)[6]:Interface GigabitEtherne
t0/0/2 has turned into UP state.
[R2]ip route-static 0.0.0.0 0.0.0.0 202.100.3.3 ====添加默认路由
[R2]ping 202.100.2.1
PING 202.100.2.1: 56 data bytes, press CTRL_C to break
Reply from 202.100.2.1: bytes=56 Sequence=1 ttl=254 time=10 ms
Reply from 202.100.2.1: bytes=56 Sequence=5 ttl=254 time=30 ms
四、配置默认路由
配置备份默认路由,当R2与R3之间链路出现故障时,可走R1。
[R2]ip route-static 0.0.0.0 0.0.0.0 202.100.1.1 preference 80
[R3]ip route-static 0.0.0.0 0.0.0.0 202.100.2.1 preference 80
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]shut
[R2-GigabitEthernet0/0/0]
[R2]tracert 202.100.2.3
traceroute to 202.100.2.3(202.100.2.3), max hops: 30 ,packet length: 40,press CTRL_C to break
1 202.100.1.1 10 ms 10 ms 10 ms
2 202.100.2.3 20 ms 20 ms 10 ms
五、了解华为不同路由协议的优先级
下载对应文档
关于博客资源下载说明
(1)第一种是书籍PDF与视频类,全部放在博客分享,觉得对大家学习有帮助的博主会收集好、然后以博主的经验整理分类后排序好分享出来。
(2)第二种是技术性文章与视频,全部放在公众号(网络之路博客)/B站(网络之路Blog)发布,以博主原创为主,主要分享系列为主,由浅入深的带大家了解工作中常用到的一些网络技术,当然也会分享一些比较经典的案例。
(3)分享资源有涉及到您的利益以及版权问题,请联系博主,24小时候内删除。
学习视频系列(总有您想要的)
Book与实验手册(从初级到高级)
数通系列(路由交换 无线、防火墙VPN等)
实战系列(最贴近企业需求的案例)
想第一时间收到最新更新内容吗,点击获取~~~