静态路由配置——两个或多个网段之间的通信

2023-09-19 00:01:01

一、实验步骤:

1、在模拟器上拉出两台路由和两台PC,分别用线缆连接好并启动。

2、PC1的网段为192.168.1.0/24,网关为192.168.1.1,PC2的网段为192.168.2.0/24,网关为19 2.168.2.1。

3、路由与路由之间的网段为:10.10.10.0/24,各接口的地址如图所示。

4、在实现PC1和PC2互通,需要在R1和R2上增加静态路由,数据通信是双向的,需要两台路由 都要加静态路由,静态路由配置命令:ip route-static 目标网段或IP地址———》子网掩码 ———》下一跳地址。

二、配置命令:

R1

sys

[Huawei]sysn R1

[R1]int g0/0/1

[R1-GigabitEthernet0/0/1]ip ad

[R1-GigabitEthernet0/0/1]ip address 192.168.1.1 24

[R1-GigabitEthernet0/0/1]int g0/0/0

[R1-GigabitEthernet0/0/0]ip ad

[R1-GigabitEthernet0/0/0]ip address 10.10.10.1 24

[R1-GigabitEthernet0/0/0]q

[R1]disp ip ro

[R1]disp ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Routing Tables: Public

Destinations : 10 Routes : 10

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.10.10.0/24 Direct 0 0 D 10.10.10.1 GigabitEthernet 0/0/0

10.10.10.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

10.10.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

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.1.0/24 Direct 0 0 D 192.168.1.1 GigabitEthernet 0/0/1

192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

[R1]ip route-s

[R1]ip route-static 192.168.2.0 24 10.10.10.2

[R1]disp ip ro

[R1]disp 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

10.10.10.0/24 Direct 0 0 D 10.10.10.1 GigabitEthernet 0/0/0

10.10.10.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

10.10.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

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.1.0/24 Direct 0 0 D 192.168.1.1 GigabitEthernet 0/0/1

192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

192.168.2.0/24 Static 60 0 RD 10.10.10.2 GigabitEthernet 0/0/0

255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

R2

sys

[Huawei]sysn R2

[R2]int g0/0/0

[R2-GigabitEthernet0/0/0]ip ad


[R2-GigabitEthernet0/0/0]ip address 10.10.10.2 24

[R2-GigabitEthernet0/0/0]int g0/0/1

[R2-GigabitEthernet0/0/1]ip ad

[R2-GigabitEthernet0/0/1]ip address 192.168.2.1 24

[R2-GigabitEthernet0/0/1]q

[R2]disp ip ro

[R2]disp ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Routing Tables: Public

Destinations : 10 Routes : 10

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.10.10.0/24 Direct 0 0 D 10.10.10.2 GigabitEthernet 0/0/0

10.10.10.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

10.10.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

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.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet 0/0/1

192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0


[R2]ip rout

[R2]ip route-s

[R2]ip route-static 192.168.1.0 24 10.10.10.1

[R2]disp 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

10.10.10.0/24 Direct 0 0 D 10.10.10.2 GigabitEthernet 0/0/0

10.10.10.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

10.10.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0

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.1.0/24 Static 60 0 RD 10.10.10.1 GigabitEthernet 0/0/0

192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet 0/0/1

192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1

255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

[R2]