1. 实验图
2. 配置流程
第1个里程: 配置SW1
1接口配置
<Huawei>sys
<Huawei>sysname S1
[Huawei]vlan batch 10 20
[Huawei]int e0/0/1
[Huawei]port link-type access
[Huawei]port default vlan 10
2接口配置
[Huawei]int e0/0/2
[Huawei]port link-type access
[Huawei]port default vlan 20
3接口配置
[Huawei]int e0/0/3
[Huawei]port link-type trunk
[Huawei]port trunk allow-pass vlan 10 20
第2个里程: 配置SW2
1接口配置
<Huawei>sys
[Huawei]sysname R2
开启dhcp
[R2]dhcp enable
创建vlan
[R2]vlan batch 10 20
[R2]int g0/0/1
配置vlan接口类型
[R2-GigabitEthernet0/0/1]port link-type trunk
允许vlan10 和vlan 20通过
[R2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
配置vlanif接口
[R2-GigabitEthernet0/0/1]int Vlanif 10
[R2-Vlanif10]ip add 192.168.10.1 24
[R2-Vlanif10]dhcp select interface
[R2-Vlanif10]int Vlanif 20
[R2-Vlanif20]ip add 192.168.20.1 24
[R2-Vlanif20]dhcp select interface
2接口配置
[R2]vlan batch 23
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]port link-type access
[R2-GigabitEthernet0/0/2]port default vlan 23
[R2-GigabitEthernet0/0/2]int vlanif 23
[R2-Vlanif23]ip add 23.0.0.2 24
第3个里程: 配置SW3
1接口配置
<Huawei>sys
[Huawei]sysname R3
[R3]vlan batch 23 13
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]port link-type access
[R3-GigabitEthernet0/0/1]port default vlan 23
[R3-GigabitEthernet0/0/1]int vlanif 23
[R3-Vlanif23]ip add 23.0.0.3 24
2接口配置
[R3-Vlanif23]int g0/0/2
[R3-GigabitEthernet0/0/2]port link-type access
[R3-GigabitEthernet0/0/2]port default vlan 13
[R3-GigabitEthernet0/0/2]int vlanif 13
[R3-Vlanif13]ip add 13.0.0.3 24
第4个里程: 配置路由器R1
<Huawei>sys
[Huawei]sysname R1
切换到接口配置ip
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 13.0.0.1 24
配置第1个子接口
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1]int g0/0/1.100
[R1-GigabitEthernet0/0/1.100]ip add 192.168.100.1 24
[R1-GigabitEthernet0/0/1.100]dot1q termination vid 100
[R1-GigabitEthernet0/0/1.100]arp broadcast enable
配置第2个子接口
[R1-GigabitEthernet0/0/1.100]int g0/0/1.200
[R1-GigabitEthernet0/0/1.200]ip add 192.168.200.1 24
[R1-GigabitEthernet0/0/1.200]dot1q termination vid 200
[R1-GigabitEthernet0/0/1.200]arp broadcast enable
第5个里程: 配置SW4
2接口配置
<Huawei>sys
[Huawei]sysname S4
创建vlan
[S4]vlan batch 100 200
[S4]int g0/0/2
设置vlan接口类型为access
[S4-GigabitEthernet0/0/2]port link-type access
加入到vlan 100
[S4-GigabitEthernet0/0/2]port default vlan 100
3接口配置
[S4-GigabitEthernet0/0/2]int g0/0/3
[S4-GigabitEthernet0/0/3]port link-type access
[S4-GigabitEthernet0/0/3]port default vlan 200
1接口配置
[S4-GigabitEthernet0/0/3]int g0/0/1
设置vlan接口类型为trunk
[S4-GigabitEthernet0/0/1]port link-type trunk
允许vlan 100 和 vlan 200通过
[S4-GigabitEthernet0/0/1]port trunk allow-pass vlan 100 200
第6个里程: 配置服务器IP地址和网关
server1
server2
第7个里程: 配置pc去往服务器的路由
sw2配置路由
[R2]ip route-s 13.0.0.0 24 23.0.0.3
[R2]ip route-s 192.168.100.0 24 23.0.0.3
[R2]ip route-s 192.168.200.0 24 23.0.0.3
SW3配置路由
<R3>sys
[R3]ip route-s 192.168.100.0 24 13.0.0.1
[R3]ip route-s 192.168.200.0 24 13.0.0.1
[R3]ip route-s 192.168.10.0 24 23.0.0.2
[R3]ip route-s 192.168.20.0 24 23.0.0.2
R1配置路由
<R1>sys
[R1]ip route-s 23.0.0.0 24 13.0.0.3
[R1]ip route-s 192.168.10.0 24 13.0.0.3
[R1]ip route-s 192.168.20.0 24 13.0.0.3
测试pc和服务器是否互通
标签:R2,int,ip,vlan,GigabitEthernet0,实验,二十四,port From: https://www.cnblogs.com/yufenchi/p/16951168.html