vlan高级配置之基于ip的vlan
实现
R1配置
[Huawei]sysname R1
[R1]
[R1]int gi0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24 给路由器接口配置ip地址
[R1-GigabitEthernet0/0/0]
核心1配置
[Huawei]vlan batch 10 20 30 200 #创建多个vlan,分别是10,20,30
[Huawei]int gi0/0/2
[Huawei-GigabitEthernet0/0/2]port link-t ac #将此接口设置为access口
[Huawei-GigabitEthernet0/0/2]port default vlan 30
[Huawei-GigabitEthernet0/0/2]
vlan 200
ip add 192.168.50.1 30
int gi0/0/1
port link-type access
port default vlan 200
[Huawei]int vlan 30
[Huawei-Vlanif30]ip add 192.168.1.2 24 给vlan30配置ip地址
[Huawei-Vlanif30]
[Huawei]int gi0/0/1
[Huawei-GigabitEthernet0/0/1]port link-t t
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[Huawei-GigabitEthernet0/0/1]
汇聚1配置
vlan 200
ip add 192.168.50.2 30
int gi0/0/4
port link-type access
port default vlan 200
批量配置1,2,3接口
[Huawei]port-group 1
[Huawei-port-group-1]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/
3
[Huawei-port-group-1]
[Huawei-port-group-1]port hybrid untagged vlan 10 20 #对于混合接口,vlan ID为10,20的不打标签
[Huawei-port-group-1]ip-subnet-vlan enable #开启ip-vlan
给vlan10,20配置ip地址
int vlan 10
ip add 192.168.10.1 25
int vlan 20 #vlan 20里有两个网段,20.0/25和200.0/25,所以配置如下
ip add 192.168.20.1 25
ip add 192.168.200.1 25 sub
ip-vlan配置
[Huawei]vlan 10
[Huawei-vlan10]ip-subnet-vlan ip 192.168.10.0 25
[Huawei-vlan10]vlan 20
[Huawei-vlan20]ip-subnet-vlan ip 192.168.20.0 25
[Huawei-vlan20]ip-subnet-vlan ip 192.168.200.0 25
添加路由
汇聚1
ip route-static 0.0.0.0 0 192.168.50.1
核心1
ip route-static 0.0.0.0 0 192.168.1.1
R1
ip route-static 192.168.0.0 16 192.168.1.2
测试
ip地址可以换成20.2 200.2 10.2,去ping 192.168.1.1
测试如下:
image.png