华为交换机配置基于IP子网划分VLAN

/ 0评 / 0

之前自己一直只会基于端口换分VLAN,基于IP子网划分VLAN的方式一直没有遇到实际用途需求,工作中遇到别人原有的网络子网IP段不够IP分配,又不想对于网络有大的改动和一台台去改电脑IP,然后只能增加划分几个VLAN,看网上的教程总是写得一知半解的,后来自己摸索研究的。配置教程如下


拓扑图:

 

大致步骤为:

1.批量创建VLAN
2.为每个VLAN配置 ip-subnet-vlan 1 ip + (IP地址)
3.配置一个端口(连接路由器的端口()为access口加入vlan 1。同时给VLANIF 1配置IP。
4.int vlanif 设IP地址
5.批量进入端口
6.在三层交换机配置静态路由到网关路由器,在路由器配置到每个VLAN 网关地址静态路由。

port link-type hybrid

port hybrid untagged vlan all

ip-subnet-vlan enable .

1.在核心三层交换机的配置:

<Huawei>
<Huawei>undo terminal monitor (关闭信息提醒)
Info: Current terminal monitor is off.
<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]vlan batch 3 6 8(批量创建VLAN 3 VLAN 6 VLAN 8)
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]vlan 3	
[Huawei-vlan3]ip-subnet-vlan 1 ip 192.168.3.1 24
[Huawei-vlan3]vlan 6	
[Huawei-vlan6]ip-subnet-vlan 1 ip 	
[Huawei-vlan6]ip-subnet-vlan 1 ip 192.168.6.1 24
[Huawei-vlan6]vlan 8
[Huawei-vlan8]ip-subnet-vlan 1 ip 192.168.8.1 24
[Huawei-vlan8]q
[Huawei]int Vlan 3 (进入VLAN 3)	
[Huawei-Vlanif3]ip address 192.168.3.1 24(配置VLAN 3网关地址)
[Huawei-Vlanif3]int vlan 6(进入VLAN 6)
[Huawei-Vlanif6]ip address 192.168.6.1 24(配置VLAN 6网关地址)
[Huawei-Vlanif6]int vlan 8(进入VLAN  8)
[Huawei-Vlanif8]ip address 192.168.8.1 24(配置VLAN 8网关地址)
[Huawei-Vlanif8]quit		
[Huawei]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/24(批量进入端口 0/0/2到0/0/24)
[Huawei-port-group]port link-type  hybrid (设置端口为hybrid)
[Huawei-GigabitEthernet0/0/2]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/3]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/4]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/5]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/6]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/7]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/8]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/9]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/10]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/11]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/12]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/13]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/14]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/15]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/16]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/17]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/18]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/19]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/20]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/21]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/22]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/23]port link-type  hybrid 
[Huawei-GigabitEthernet0/0/24]port link-type  hybrid 	
[Huawei-port-group]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/2]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/3]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/4]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/5]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/6]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/7]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/8]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/9]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/10]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/11]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/12]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/13]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/14]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/15]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/16]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/17]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/18]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/19]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/20]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/21]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/22]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/23]port hybrid untagged vlan all
[Huawei-GigabitEthernet0/0/24]port hybrid untagged vlan all
[Huawei-port-group]ip-subnet-vlan enable (开启ip-subnet-vlan)
[Huawei-GigabitEthernet0/0/2]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/3]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/4]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/5]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/6]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/7]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/8]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/9]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/10]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/11]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/12]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/13]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/14]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/15]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/16]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/17]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/18]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/19]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/20]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/21]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/22]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/23]ip-subnet-vlan enable 
[Huawei-GigabitEthernet0/0/24]ip-subnet-vlan enable 
[Huawei-port-group]quit
[Huawei]vlan 2(创建VLAN 2)
[Huawei-vlan2]quit
[Huawei]int GigabitEthernet 0/0/1(进入端口1,此端口与网关路由器连接)
[Huawei-GigabitEthernet0/0/1]port link-type access (设置端口为access)
[Huawei-GigabitEthernet0/0/1]port default vlan 2(将此端口加入到VLAN 2中)
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]int Vlanif 2(进入VLAN 2)
[Huawei-Vlanif2]ip address 192.168.1.1 24(设置IP地址为192.168.1.1 子网掩码为 255.255.255.0)
[Huawei-Vlanif2]quit
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2(配置一条到网关路由器的静态路由,同时是去往任何网络的静态路由,下一跳地址为路由器的192.168.1.2)
[Huawei]

配置界面截图:

2.路由器配置:

<Huawei>undo terminal monitor (关闭消息提醒)
Info: Current terminal monitor is off.
<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]int Ethernet 0/0/1(进入端口 Ethernet 0/0/1)
[Huawei-Ethernet0/0/1]ip address 192.168.1.2 24(设置IP地址为 192.168.1.2 子网掩码为 255.255.255.0)	
[Huawei-Ethernet0/0/1]quit 
[Huawei]ip route-static 192.168.0.0 255.255.0.0 192.168.1.1(配置一条到交换机每个VLAN 的静态路由,因为都是192.168开头的网段,可以合并为一起写,下一跳地址为交换机的 0/0/2口192.168.1.1)
[Huawei]ping 192.168.6.2(ping PC1是否静态路由有写成功)
  PING 192.168.6.2: 56  data bytes, press CTRL_C to break
    Reply from 192.168.6.2: bytes=56 Sequence=1 ttl=127 time=70 ms
    Reply from 192.168.6.2: bytes=56 Sequence=2 ttl=127 time=60 ms
    Reply from 192.168.6.2: bytes=56 Sequence=3 ttl=127 time=50 ms
    Reply from 192.168.6.2: bytes=56 Sequence=4 ttl=127 time=40 ms
    Reply from 192.168.6.2: bytes=56 Sequence=5 ttl=127 time=40 ms

  --- 192.168.6.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 40/52/70 ms

[Huawei]

3.三台PC可以互相Ping通和可以Ping通路由器

发表回复