1.什么是静态路由?
静态路由是由用户管理员在路由器中手动配置的固定路由,因为是人工配置的,所以当网络的拓扑结构或链路的状态发生变化时,需要我们手动修改路由表里面的相关信息。
是一种路由的方式,路由项(routing entry)由手动配置,而非动态决定。与动态路由不同,静态路由是固定的,不会改变,即使网络状况已经改变或是重新被组态。一般来说,静态路由是由网络管理员逐项加入路由表。
2.静态路由的特点
(1)静态路由固定了路径的转发,因此对路由器的路由选择进行控制,节省了网络带宽,减少了额外开支;
(2)静态路由是单向的,它只设定了从此路由设备转发到目标出去的路径;
(3)静态路由是缺乏灵活性的,网络发送变化时需要人工进行配置修改。
具体配置
1.搭建这个拓扑图
2.进入pc进行配置
3.进入路由器进行配置,首先先进入R1
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en //关闭提示信息
Info: Information center is disabled.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.10.254 24 //配置端口IP
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.20.1 24
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ip route-static 192.168.30.0 255.255.255.0 192.168.20.2 //配置目标网段192.168.2.0的静态条目,第一个是目标的网段,第一个是目标网段的子网掩码,第三个就是下一条
[Huawei]dis ip routing-table //查看路由条目
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
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
192.168.10.0/24 Direct 0 0 D 192.168.10.254 GigabitEthernet
0/0/0
192.168.10.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Direct 0 0 D 192.168.20.1 GigabitEthernet
0/0/1
192.168.20.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.30.0/24 Static 60 0 RD 192.168.20.2 GigabitEthernet
0/0/1
[Huawei] User interface con0 is available
Please Press ENTER.
进入R2进行配置
The device is running!
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]un in en //关闭提示信息
Info: Information center is disabled.
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.20.2 24 //配置端口IP
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.30.254 24
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip route-static 192.168.10.0 255.255.255.0 192.168.20.1 //配置目标网段192.168.2.0的静态条目,第一个是目标的网段,第一个是目标网段的子网掩码,第三个就是下一条
[Huawei]dis ip routing-table //查看路由条目
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
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
192.168.10.0/24 Static 60 0 RD 192.168.20.1 GigabitEthernet
0/0/1
192.168.20.0/24 Direct 0 0 D 192.168.20.2 GigabitEthernet
0/0/1
192.168.20.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.30.0/24 Direct 0 0 D 192.168.30.254 GigabitEthernet
0/0/0
192.168.30.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
[Huawei] User interface con0 is available
Please Press ENTER.
4.查看pc间的互通