静态路由由网络管理员手动配置,配置方便,对系统要求低,适用于拓扑结构简单并且稳定的小型网络。
缺点是不能自动适应网络拓扑的变化,需要人工干预。
配置命令
1、关联下一跳IP的方式
[Huawei] ip route-static ip-address { mask | mask-length } nexthop-address
2、关联出接口的方式
[Huawei] ip route-static ip-address { mask | mask-length } interface-type interface-number
3、关联出接口和下一跳IP方式
[Huawei] ip route-static ip-address { mask | mask-length } interface-type interface-number [ nexthop-address ]
在创建静态路由时,可以同时指定出接口和下一跳。对于不同的出接口类型,也可以只指定出接口或只指定下一跳。
对于点到点接口(如串口),必须指定出接口。
配置举例
![](https://i-blog.csdnimg.cn/blog_migrate/628cc5792bb8107e476e87869fe9ba3e.png)
RTA
与
RTC
上配置静态路由,实现
10.0.0.0/24
与
20.1.1.0/24
的互通。
因为报文
是逐跳转发
的,
所以
每一跳
路由
设备上都需要
配置到达相应
目的地址的路由。
另外需要注意通信是双向的
,针对通信过程中的往返流量,都需关注途径设备上的路由配置。
RTA
system-view
sysname RTA
interface GigabitEthernet 0/0/0
ip address 10.0.0.1 255.255.255.0
quit
ip route-static 20.1.1.0 255.255.255.0 10.0.0.2
RTB
system-view
sysname RTB
interface GigabitEthernet 0/0/0
ip address 10.0.0.2 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 20.1.1.2 255.255.255.0
RTC
system-view
sysname RTC
interface GigabitEthernet 0/0/1
ip address 20.1.1.1 255.255.255.0
quit
ip route-static 10.0.0.0 255.255.255.0 20.1.1.2