【网络】配置VLANIF接口实现VLAN间的通信示例

【网络】配置VLANIF接口实现VLAN间的通信示例_第1张图片

组网需求:

配置S5700-28C-HI交换机的二层接口G0/0/1和G0/0/2分别与PC相连,PC1和PC2属于不同的网段。
通过配置不同的VLAN,将二层的广播报文限制在各VLAN内;通过配置VLANIF接口,VLAN间可以经VLANIF三层接口路由转发报文,实现VLAN间的通信。

配置步骤

1.S5700-28C-HI交换机的配置

system-view                                          #进入系统视图
[Huawei]sysname  S5700-28C-HI                                #配置交换机的名称为 S5700-28C-HI 
[S5700-28C-HI]vlan batch 10 20                               #批量创建 VALN 10 和 VLAN 20
[S5700-28C-HI]interface  Vlanif  10                          #进入VLANIF10接口
[S5700-28C-HI-Vlanif10]ip address 10.10.10.1 24              #配置IP地址为 10.10.10.1,掩码长度为24位
[S5700-28C-HI-Vlanif10]quit                                  #退出VLANIF10接口
[S5700-28C-HI]interface  Vlanif  20                          #进入VLANIF 20接口
[S5700-28C-HI-Vlanif20]ip address  10.10.20.1 24             #配置IP地址位 10.10.20.1,掩码长度为24位
[S5700-28C-HI-Vlanif20]quit                                  #退出VLANIF 20接口
[S5700-28C-HI]interface  GigabitEthernet  0/0/1              #进入千兆以太网接口 G 0/0/1
[S5700-28C-HI-GigabitEthernet0/0/1]port link-type access     #配置端口链路类型位ACCESS
[S5700-28C-HI-GigabitEthernet0/0/1]port default  vlan  10    #配置端口的默认VLAN为10
[S5700-28C-HI-GigabitEthernet0/0/1]quit                      #退出千兆接口 G0/0/1
[S5700-28C-HI]interface   GigabitEthernet 0/0/2              #进入千兆以太网接口 G0/0/2
[S5700-28C-HI-GigabitEthernet0/0/2]port link-type access     #配置端口的链路类型为 ACCESS
[S5700-28C-HI-GigabitEthernet0/0/2]port default vlan 20      #配置端口的默认VLAN 为20

2.PC1的配置

【网络】配置VLANIF接口实现VLAN间的通信示例_第2张图片3. PC2的配置
【网络】配置VLANIF接口实现VLAN间的通信示例_第3张图片

验证配置

1.PC 1上ping 测试
分别ping :
自己的网关 10.10.10.1 ,
对方的网段 10.10.20.1
对方的IP地址 10.10.20.2

Welcome to use PC Simulator!

PC>ping 10.10.10.1

Ping 10.10.10.1: 32 data bytes, Press Ctrl_C to break
From 10.10.10.1: bytes=32 seq=1 ttl=255 time=16 ms
From 10.10.10.1: bytes=32 seq=2 ttl=255 time=15 ms
From 10.10.10.1: bytes=32 seq=3 ttl=255 time=16 ms
From 10.10.10.1: bytes=32 seq=4 ttl=255 time=15 ms
From 10.10.10.1: bytes=32 seq=5 ttl=255 time=15 ms

--- 10.10.10.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/15/16 ms

PC>ping 10.10.20.1

Ping 10.10.20.1: 32 data bytes, Press Ctrl_C to break
From 10.10.20.1: bytes=32 seq=1 ttl=255 time=16 ms
From 10.10.20.1: bytes=32 seq=2 ttl=255 time=15 ms
From 10.10.20.1: bytes=32 seq=3 ttl=255 time=31 ms
From 10.10.20.1: bytes=32 seq=4 ttl=255 time=32 ms
From 10.10.20.1: bytes=32 seq=5 ttl=255 time=31 ms

--- 10.10.20.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/25/32 ms

PC>ping 10.10.20.2

Ping 10.10.20.2: 32 data bytes, Press Ctrl_C to break
From 10.10.20.2: bytes=32 seq=1 ttl=127 time=78 ms
From 10.10.20.2: bytes=32 seq=2 ttl=127 time=63 ms
From 10.10.20.2: bytes=32 seq=3 ttl=127 time=46 ms
From 10.10.20.2: bytes=32 seq=4 ttl=127 time=32 ms
From 10.10.20.2: bytes=32 seq=5 ttl=127 time=47 ms

--- 10.10.20.2 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 32/53/78 ms

PC>

2 .PC 1上ping 测试
分别ping :
自己的网关 10.10.20.1 ,
对方的网段 10.10.10.1
对方的IP地址 10.10.10.2

Welcome to use PC Simulator!

PC>ping 10.10.20.1

Ping 10.10.20.1: 32 data bytes, Press Ctrl_C to break
From 10.10.20.1: bytes=32 seq=1 ttl=255 time=31 ms
From 10.10.20.1: bytes=32 seq=2 ttl=255 time=16 ms
From 10.10.20.1: bytes=32 seq=3 ttl=255 time=32 ms
From 10.10.20.1: bytes=32 seq=4 ttl=255 time=15 ms
From 10.10.20.1: bytes=32 seq=5 ttl=255 time=16 ms

--- 10.10.20.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/22/32 ms

PC>ping 10.10.10.1

Ping 10.10.10.1: 32 data bytes, Press Ctrl_C to break
From 10.10.10.1: bytes=32 seq=1 ttl=255 time=16 ms
From 10.10.10.1: bytes=32 seq=2 ttl=255 time=31 ms
From 10.10.10.1: bytes=32 seq=3 ttl=255 time=16 ms
From 10.10.10.1: bytes=32 seq=4 ttl=255 time=31 ms
From 10.10.10.1: bytes=32 seq=5 ttl=255 time=16 ms

--- 10.10.10.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 16/22/31 ms

PC>ping 10.10.10.2

Ping 10.10.10.2: 32 data bytes, Press Ctrl_C to break
From 10.10.10.2: bytes=32 seq=1 ttl=127 time=32 ms
From 10.10.10.2: bytes=32 seq=2 ttl=127 time=32 ms
From 10.10.10.2: bytes=32 seq=3 ttl=127 time=31 ms
From 10.10.10.2: bytes=32 seq=4 ttl=127 time=63 ms
From 10.10.10.2: bytes=32 seq=5 ttl=127 time=46 ms

--- 10.10.10.2 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 0/43/63 ms

PC>

3.测试结论
PC 1 和PC 2 之间可以互相PING 通。

你可能感兴趣的:(vlanif,网络,华为,ensp,交换机)