2eew 发表于 2016-1-18 09:57:21

华为IPv4静态路由配置示例

IPv4静态路由配置示例

组网需求
如图1所示,属于不同网段的主机通过几台Switch相连,要求不配置动态路由协议,使不同网段的任意两台主机之间能够互通。
http://localhost:7890/pages/31187420/04/31187420/04/resources/dc/images/fig_dc_cfg_static-route_002701.png
图1 配置IP静态路由组网图

配置思路
采用如下的思路配置IPv4静态路由:
创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址,实现相邻设备网络互通。
在各主机上配置IP缺省网关,在各台Switch上配置IPv4静态路由或者静态缺省路由,实现不配置动态路由协议,使不同网段的任意两台主机之间能够互通。

操作步骤
1、配置各接口所属VLAN
# 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。
<HUAWEI> system-view
sysname SwitchA
vlan batch 10 30
interface gigabitethernet 1/0/1
portlink-type trunk
port trunkallow-pass vlan 10
quit
interface gigabitethernet 1/0/2
portlink-type access
port defaultvlan 30
quit

2、配置各VLANIF接口的IP地址
# 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。
interface vlanif 10
ip address 10.1.4.1 30
quit
interface vlanif 30
ip address 10.1.1.1 24
quit

3、配置主机
配置主机PC1的缺省网关为10.1.1.1,主机PC2的缺省网关为10.1.2.1,主机PC3的缺省网关为10.1.3.1。
配置静态路由
# 在SwitchA配置IP缺省路由。
ip route-static 0.0.0.0 0.0.0.010.1.4.2

# 在SwitchB配置两条IP静态路由。
ip route-static 10.1.1.0255.255.255.0 10.1.4.1
ip route-static 10.1.3.0255.255.255.0 10.1.4.6

# 在SwitchC配置IP缺省路由。
ip route-static 0.0.0.0 0.0.0.010.1.4.5

4、验证配置结果
#查看SwitchA的IP路由表。
display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
      Destinations : 7      Routes : 7

Destination/Mask    Proto PreCost   FlagsNextHop      Interface

       0.0.0.0/0    Static 60   0       RD   10.1.4.2   Vlanif10
       10.1.1.0/24Direct 0    0       D    10.1.1.1   Vlanif30
       10.1.1.1/32Direct 0    0       D    127.0.0.1    Vlanif30
       10.1.4.0/30Direct 0    0       D    10.1.4.1    Vlanif10
       10.1.4.1/32Direct 0    0       D    127.0.0.1    Vlanif10
   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

# 使用ping命令验证连通性。
ping 10.1.3.1
PING 10.1.3.1: 56data bytes,press CTRL_C to break
   Reply from 10.1.3.1: bytes=56 Sequence=1 ttl=253 time=62 ms
   Reply from 10.1.3.1: bytes=56 Sequence=2 ttl=253 time=63 ms
   Reply from 10.1.3.1: bytes=56 Sequence=3 ttl=253 time=63 ms
   Reply from 10.1.3.1: bytes=56 Sequence=4 ttl=253 time=62 ms
   Reply from 10.1.3.1: bytes=56 Sequence=5 ttl=253 time=62 ms
---10.1.3.1 ping statistics ---
    5packet(s) transmitted
    5packet(s) received
   0.00% packet loss
   round-trip min/avg/max = 62/62/63 ms

# 使用Tracert命令验证连通性。
tracert 10.1.3.1
traceroute to 10.1.3.1(10.1.3.1), max hops: 30 ,packet length: 40,press CTRL_C tobreak
110.1.4.2 31 ms32 ms31 ms
210.1.3.1 62 ms63 ms62 ms

5、配置文件

SwitchA的配置文件
#
sysname SwitchA
#
vlan batch 10 30
#
interface Vlanif10
ipaddress 10.1.4.1 255.255.255.252
#
interface Vlanif30
ipaddress 10.1.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
portlink-type trunk
porttrunk allow-pass vlan 10
#
interface GigabitEthernet1/0/2
portlink-type access
portdefault vlan 30
#
ip route-static 0.0.0.0 0.0.0.0 10.1.4.2
#
return


SwitchB的配置文件
#
sysname SwitchB
#
vlan batch 10 20 40
#
interface Vlanif10
ipaddress 10.1.4.2 255.255.255.252
#
interface Vlanif20
ipaddress 10.1.4.5 255.255.255.252
#
interface Vlanif40
ipaddress 10.1.2.1 255.255.255.0
#
interface GigabitEthernet1/0/1
portlink-type trunk
porttrunk allow-pass vlan 10
#
interface GigabitEthernet1/0/2
portlink-type trunk
porttrunk allow-pass vlan 20
#
interface GigabitEthernet1/0/3
portlink-type access
portdefault vlan 40
#
ip route-static 10.1.1.0 255.255.255.010.1.4.1
ip route-static 10.1.3.0 255.255.255.010.1.4.6
#
return


SwitchC的配置文件
#
sysname SwitchC
#
vlan batch 20 50
#
interface Vlanif20
ipaddress 10.1.4.6 255.255.255.252
#
interface Vlanif50
ipaddress 10.1.3.1 255.255.255.0
#
interface GigabitEthernet1/0/1
portlink-type trunk
porttrunk allow-pass vlan 20
#
interface GigabitEthernet1/0/2
portlink-type access
portdefault vlan 50
#
ip route-static 0.0.0.0 0.0.0.0 10.1.4.5
#
return



页: [1]
查看完整版本: 华为IPv4静态路由配置示例