静态路由

路由概括

路由:从源主机到目标的转发过程

路由表的形式

路由器中维护的路由条目的集合
路由表根据路由表做路径选择

根据路由表转发数据

在这里插入图片描述

路由表的形式

直接网段
配置IP地址、端口哈UP状态、形成直连路由
非直连网段

在这里插入图片描述

静态路由

静态路由是由管理员在路由器中手动配置的固定路由。

要到达的目的网络:192.168.1.0/24
与路由器A直连的下一个路由器B的接口IP地址或者路由器A的本地接口。
静态路由是管理手动设置的,除非网络管理员干预,否则静态路由不会发生变化。
允许对路由的行为进行精确的控制。
静态路由是单向的。
静态路由的不足是之处是缺乏灵活性。
吓一跳:10.0.0.1

默认路由

当路由器在路由表中找不到目标网络的路由条目时,路由器把请求转发到默认路由接口。
默认路由:0.0.0.0 stud netwsrk:末节网络
路由优先级、数字越小、越优先

路由器转发数据包的封装过程

源目地址变化
路由器是隔离广播
HostA知道自己的mck跟B通信,在A主机上

交换与路由对比

路由工作在网络层

根据“路由表”转发数据
路由选择
路由转发

交换工作在数据链路层

根据“MAC地址表”转发数据
硬件转发

配置命令

network:目的网络地址
mask:子网掩码
address:到达目的网络经过的下一条路由器的接口地址
inferface:到达目的网络的本地接口地址
ip route-static:配置静态路由 静态值60
dis ip routing-table:查看mck地址
undoip:删除
preference:浮动

配置默认路由

默认路由的配置命令格式与静态路由一样,只是在目的网络部分不同。
“0.0.0.0 0.0.0.0”:代表任何网络,也就是说发往任何网络的数据包都转发到命令指定的下一个路由器接口地址。
address:到达目的网络经过的下一条路由器的接口地址

作业

1

在这里插入图片描述

R1配置命令
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 10.0.2.2
^
Error:Incomplete command found at ‘^’ position.
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.0.1.1 8
Apr 5 2021 22:06:11-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add
^
Error:Incomplete command found at ‘^’ position.
[R1-GigabitEthernet0/0/2]ip add 192.168.10.2
^
Error:Incomplete command found at ‘^’ position.
[R1-GigabitEthernet0/0/2]ip add 192.168.10.2 24
Apr 5 2021 22:07:22-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R1-GigabitEthernet0/0/2]q
[R1]ip ro
[R1]ip route-s
[R1]ip route-static 192.168.20.0 24 10.0.2.1
[R1]ip ro
[R1]ip route-s
[R1]ip route-static 192.168.30.0 24 10.0.1.2
[R1]
R2配置命令
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.20.2 24
Apr 5 2021 22:10:05-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 10.0.2.1 8
Apr 5 2021 22:11:01-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-GigabitEthernet0/0/1]q
[R2]ip ro
[R2]ip route-s
[R2]ip route-static 192.168.10.0 24 10.0.2.2
[R2]ip ro
[R2]ip route-s
[R2]ip route-static 192.168.30.0 24 10.0.2.2
R3配置命令
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 10.0.1.2 8
Apr 5 2021 22:15:11-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.30.2 24
Apr 5 2021 22:15:54-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R3-GigabitEthernet0/0/1]q
[R3]ip ro
[R3]ip route-
[R3]ip route-static 192.168.10.0 24 10.0.1.1
[R3]ip ro
^
Error:Ambiguous command found at ‘^’ position.
[R3]ip ro
[R3]ip route-s
[R3]ip route-static 192.168.20.0 24 10.0.1.1
PC1连通PC2与PC3
在这里插入图片描述
PC2连通PC1与PC3
在这里插入图片描述
PC3连通PC1与PC2

在这里插入图片描述

2

在这里插入图片描述
The device is running!

sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys r1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.10.254 24
Apr 7 2021 00:34:09-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 10.0.0.1 24
Apr 7 2021 00:34:36-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r1-GigabitEthernet0/0/1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip add 20.0.0.1 24
Apr 7 2021 00:35:15-08:00 r1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[r1-GigabitEthernet0/0/2]q
[r1]ip ro
[r1]ip route-s
[r1]ip route-static 192.168.20.0 24 10.0.0.2
[r1]ip ro
[r1]ip route
[r1]ip route-static 192.168.20.0 24 20.0.0.2
[r1]ip ro
[r1]ip route-s
[r1]ip route-static 192.168.20.0 24 20.0.0.2 preference 70
Info: Succeeded in modifying route.
The device is running!

sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 10.0.0.2 24
Apr 7 2021 00:39:05-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 192.168.20.254 24
Apr 7 2021 00:39:35-08:00 r2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r2-GigabitEthernet0/0/1]int g0/0/2
[r2-GigabitEthernet0/0/2]ip add 30.0.0.1 24
[r2-GigabitEthernet0/0/2]
Apr 7 2021 00:40:01-08:00 r2 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[r2-GigabitEthernet0/0/2]q
[r2]dis cu
[V200R003C00]

sysname r2

snmp-agent local-engineid 800007DB03000000000000
snmp-agent

clock timezone China-Standard-Time minus 08:00:00

portal local-server load portalpage.zip

drop illegal-mac alarm

set cpu-usage threshold 80 restore 75

aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher % % K8m.Nt84DZ}e#<0`8bmE3Uw}% %
local-user admin service-type http

firewall zone Local
priority 15

interface GigabitEthernet0/0/0
ip address 10.0.0.2 255.255.255.0

interface GigabitEthernet0/0/1
ip address 192.168.20.254 255.255.255.0

interface GigabitEthernet0/0/2
ip address 30.0.0.1 255.255.255.0

interface NULL0

user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20

wlan ac

return
[r2]ip ro
[r2]ip route-s
[r2]ip route-static 192.168.10.0 24 10.0.0.1
[r2]ip ro
[r2]ip route-s
[r2]ip route-static 192.168.10.0 24 30.0.0.2
[r2]dis cu
[V200R003C00]

sysname r2

snmp-agent local-engineid 800007DB03000000000000
snmp-agent

clock timezone China-Standard-Time minus 08:00:00

portal local-server load portalpage.zip

drop illegal-mac alarm

set cpu-usage threshold 80 restore 75

aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher % % K8m.Nt84DZ}e#<0`8bmE3Uw}% %
local-user admin service-type http

firewall zone Local
priority 15

interface GigabitEthernet0/0/0
ip address 10.0.0.2 255.255.255.0

interface GigabitEthernet0/0/1
ip address 192.168.20.254 255.255.255.0

interface GigabitEthernet0/0/2
ip address 30.0.0.1 255.255.255.0

interface NULL0

ip route-static 192.168.10.0 255.255.255.0 10.0.0.1
ip route-static 192.168.10.0 255.255.255.0 30.0.0.2

user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20

wlan ac
The device is running!

sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys r3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 20.0.0.2 24
Apr 7 2021 00:42:54-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 30.0.0.2 24
Apr 7 2021 00:43:24-08:00 r3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r3-GigabitEthernet0/0/1]q
[r3]ip ro
[r3]ip route-s
[r3]ip route-static 192.168.10.0 24 20.0.0.1
[r3]ip ro
[r3]ip route-s
[r3]ip route-static 192.168.20.0 24 30.0.0.1
[r3]dis ip ro
[r3]dis ip routing-table
Route Flags: R - relay, D - download to fib

Routing Tables: Public
Destinations : 12 Routes : 12

Destination/Mask Proto Pre Cost Flags NextHop Interface

   20.0.0.0/24  Direct  0    0           D   20.0.0.2        GigabitEthernet

0/0/0
20.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
20.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
30.0.0.0/24 Direct 0 0 D 30.0.0.2 GigabitEthernet
0/0/1
30.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
30.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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
192.168.10.0/24 Static 60 0 RD 20.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Static 60 0 RD 30.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

PC1PC2的ping结果,连通正常

Welcome to use PC Simulator!

PC>ping 192.168.10.1

Ping 192.168.10.1: 32 data bytes, Press Ctrl_C to break
From 192.168.10.1: bytes=32 seq=1 ttl=126 time=15 ms
From 192.168.10.1: bytes=32 seq=2 ttl=126 time=16 ms
From 192.168.10.1: bytes=32 seq=3 ttl=126 time=16 ms
From 192.168.10.1: bytes=32 seq=4 ttl=126 time=16 ms
From 192.168.10.1: bytes=32 seq=5 ttl=126 time=31 ms

— 192.168.10.1 ping statistics —
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/18/31 ms

PC>
Welcome to use PC Simulator!

PC>ping 192.168.20.1

Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
From 192.168.20.1: bytes=32 seq=3 ttl=126 time=31 ms
From 192.168.20.1: bytes=32 seq=4 ttl=126 time=16 ms
From 192.168.20.1: bytes=32 seq=5 ttl=126 time=16 ms

— 192.168.20.1 ping statistics —
5 packet(s) transmitted
3 packet(s) received
40.00% packet loss
round-trip min/avg/max = 0/21/31 ms
pc1与pc2依旧可以连通
PC>ping 192.168.10.1

Ping 192.168.10.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
From 192.168.10.1: bytes=32 seq=4 ttl=125 time=32 ms
From 192.168.10.1: bytes=32 seq=5 ttl=125 time=31 ms

— 192.168.10.1 ping statistics —
5 packet(s) transmitted
2 packet(s) received
60.00% packet loss

3 在这里插入图片描述

sys

Enter system view, return user view with Ctrl+Z.
[Huawei]sys r1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
Apr 7 2021 01:03:54-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 192.168.2.254 24
Apr 7 2021 01:04:28-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r1-GigabitEthernet0/0/1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip add 192.168.10.1 24
[r1-GigabitEthernet0/0/2]
Apr 7 2021 01:05:04-08:00 r1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[r1-GigabitEthernet0/0/2]q
[r1]ip ro
[r1]ip route-s
[r1]ip route-static 0.0.0.0 0 192.168.10.2

sys

Enter system view, return user view with Ctrl+Z.
[Huawei]sys r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.10.2 24
Apr 7 2021 01:06:55-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 192.168.20.1 24
[r2-GigabitEthernet0/0/1]
Apr 7 2021 01:07:29-08:00 r2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r2-GigabitEthernet0/0/1]q
[r2]ip ro
[r2]ip route-s
[r2]ip route-static 10.0.0.0 8 192.168.20.2
[r2]ip ro
[r2]ip route-s
[r2]ip route-static 192.168.1.0 24 192.168.10.1
[r2]ip ro
[r2]ip route-s
[r2]ip route-static 192.168.2.0 25 192.168.10.1

sys

Enter system view, return user view with Ctrl+Z.
[Huawei]sys r3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 192.168.20.2 24
Apr 7 2021 01:08:13-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 10.0.0.1 8
Apr 7 2021 01:08:40-08:00 r3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r3-GigabitEthernet0/0/1]q
[r3]ip ro
[r3]ip route-s
[r3]ip route-static 192.168.1.0 24 192.168.20.1
[r3]ip ro
[r3]ip route-s
[r3]ip route-static 192.168.2.0 24 192.168.20.1

PC>ping 192.168.2.10

Ping 192.168.2.10: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.10: bytes=32 seq=2 ttl=127 time<1 ms
From 192.168.2.10: bytes=32 seq=3 ttl=127 time<1 ms
From 192.168.2.10: bytes=32 seq=4 ttl=127 time=15 ms
From 192.168.2.10: bytes=32 seq=5 ttl=127 time=16 ms

— 192.168.2.10 ping statistics —
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/7/16 ms

PC>ping 192.168.1.10

Ping 192.168.1.10: 32 data bytes, Press Ctrl_C to break
From 192.168.1.10: bytes=32 seq=1 ttl=127 time=16 ms
From 192.168.1.10: bytes=32 seq=2 ttl=127 time=15 ms
From 192.168.1.10: bytes=32 seq=3 ttl=127 time=16 ms
From 192.168.1.10: bytes=32 seq=4 ttl=127 time=15 ms
From 192.168.1.10: bytes=32 seq=5 ttl=127 time<1 ms

— 192.168.1.10 ping statistics —
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 0/12/16 ms

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值