配置说明
IPv4 Routing
# 关联下一跳 IP 的方式 [Huawei] ip route-static <ip-address> <mask> <nexthop-address> # 关联出接口的方式 [Huawei] ip route-static <ip-address> <mask> <interface-type> <interface-number> # 仅能用在 PPP 协议中 # 关联出接口和下一跳 IP 方式 [Huawei] ip route-static <ip-address> <mask> <interface-type> <interface-number> <nexthop-address>
在创建静态路由时,可以同时指定出接口和下一跳;
对于不同的出接口类型,由于路由递归特性,所以可以只指定出接口或只指定下一跳;
对于点到点接口(如串口),指定出接口;
对于广播接口(如以太网接口)和 VT(Virtual-Template)接口,必须指定下一跳;
在华为设备中,当配置静态路由时,如果未指定出接口,而是直接指定下一跳,则需要对端开启 ARP Proxy 特性,然后设备会直接 ARP 查询目标网络 MAC 地址;
IPv6 Routing
// 在公网上配置 IPv6 静态路由; [Huawei] ipv6 route-static dest-ipv6-address prefix-length { interface-type interface-number [ nexthop-ipv6-address ] | nexthop-ipv6-address | vpn-instance vpn-destination-name nexthop-ipv6-address } [ preference preference][ permanent | inherit-cost ] [ description text ] preference preference:指定路由优先级。整数形式,取值范围为 1~255。缺省值是 60; permanent:指定 IPv6 静态路由永久发布; inherit-cost:指定 IPv6 静态路由继承迭代路由的开销值; description text:指定静态路由的描述信息。字符串形式,支持空格,长度范围是 1~80; // 在 VPN 实例下配置 IPv6 静态路由; [Huawei] ipv6 route-static vpn-instance vpn-instance-name dest-ipv6-address prefix-length { [ interface-type interface-number [ nexthop-ipv6-address ] ] | nexthop-ipv6-address [ public ] | vpn-instance vpn-destination-name nexthop-ipv6-address } [ preference preference ] [ permanent | inherit-cost ] [ description text ] public:指定 nexthop-ipv6-address 是公网地址,而不是源 VPN 中的地址;
注意事项:
静态路由如果不配置优先级,默认优先级为 60;
如果将目的地址与前缀长度都配置为全 0(::0),则表示配置的是缺省路由(::/0);
undo 命令中配置参数 permanent 时,只能取消 IPv6 静态路由永久发布,不能删除 IPv6 静态路由;
配置示例
在 RTB 上,添加静态路由:
1)使用 10.0.12.1 作为下一跳地址(该地址用作二层查询 MAC 地址)
2)使用 Serial 1/0/0 作为出接口
这里分开配置下一跳与出接口,是因为这里是直连路由(串行接口、点对点),通过下一跳能够递归查询得到出接口:
但是,在广播型接口(以太网络)中,必须使用下一跳地址,而不能使用出接口: