H3C S5024P交换机第二次vlan实验
与交换机端口G0/1和G0/2相连的PC1与PC2属于VLAN 1,与G0/3和G0/4相连的PC3和PC4属于VLAN 2,PC1、PC2、PC3、PC4在相同的网段。要求PC1、PC2之间能够互相通信,PC3、PC4之间能够互相通信,PC1、PC2和PC3、PC4之间不能通信
所谓在相同的网段,就是ip地址的网络部分是一样的,这是由子网掩码决定的,由子网掩码和ip地址计算出网络部分,一样的话就叫相同的网段。
Quidway>reboot
[Quidway] sysname Switch2
Sw1-Vlan1]display vlan 1
VLAN State: 802.1q VLAN
VLAN ID: 1
VLAN Type: static
Route Interface: configured
IP Address: 10.0.0.2
Subnet Mask: 255.0.0.0
Tagged Ports: none
Untagged Ports:
GigabitEthernet0/1 GigabitEthernet0/2 GigabitEthernet0/3
GigabitEthernet0/4 GigabitEthernet0/5 GigabitEthernet0/6
GigabitEthernet0/7 GigabitEthernet0/8 GigabitEthernet0/9
GigabitEthernet0/10 GigabitEthernet0/11 GigabitEthernet0/12
GigabitEthernet0/13 GigabitEthernet0/14 GigabitEthernet0/15
GigabitEthernet0/16 GigabitEthernet0/17 GigabitEthernet0/18
GigabitEthernet0/19 GigabitEthernet0/20 GigabitEthernet0/21
GigabitEthernet0/22 GigabitEthernet0/23 GigabitEthernet0/24
<Quidway> sys
[Quidway] sysname Switch1
[Switch1] interface Vlan-interface 1
[Switch1-Vlan-interface] ip addr 192.168.10.1 255.255.255.0
[switch2-Vlan1]vlan 2
[switch2-Vlan2]port g0/3
[switch2-Vlan2]port g0/4
[switch2-Vlan2]display vlan 2
VLAN State: 802.1q VLAN
VLAN ID: 2
VLAN Type: static
Route Interface: not configured
Tagged Ports: none
Untagged Ports:
GigabitEthernet0/3 GigabitEthernet0/4
我在 192.168.10.3里
ping vlan2 同一个网能通 ping 192.168.10.5就不通
PC1,PC2分别与交换机Switch1的g0/10和g0/20端口( g0/10属于VLAN3, g0/20属于VLAN2)相连,PC3和PC4与Switch2的g0/11和g0/21端口(g0/11属于VLAN2, g0/21属于VLAN3)相连,PC1、PC2 、PC3 、PC4都在相同的网段。要求PC1和PC4之间能够互相通信, PC3和PC2之间能够互相通信,请设计2种连线方法和配置.
<switch2>vlan 2
^
% Unrecognized command found at '^' position.
<switch2>sys
Enter system view, return to user view with Ctrl+Z.
[switch2]vlan 2
[switch2-Vlan2]undo port g0/3
[switch2-Vlan2]undo port g0/4
[switch2-Vlan2]port g0/11
[switch2-Vlan2]vlan 3
[switch2-Vlan3]port g0/21
[switch2-Vlan3]display vlan 3
VLAN State: 802.1q VLAN
VLAN ID: 3
VLAN Type: static
Route Interface: not configured
Tagged Ports: none
Untagged Ports:
GigabitEthernet0/21
[switch2-Vlan3]display vlan 2
VLAN State: 802.1q VLAN
VLAN ID: 2
VLAN Type: static
Route Interface: not configured
Tagged Ports: none
Untagged Ports:
GigabitEthernet0/11
首先要进入以太网端口视图
[switch2-Vlan3]interface g0/22
[switch2-GigabitEthernet0/22]port link-type trunk
[switch2-GigabitEthernet0/22]port trunk pvid vlan 100
[switch2-GigabitEthernet0/22]port trunk permit vlan 2 to 3 允许2和3vlan的帧通过
[switch2-GigabitEthernet0/22]
<switch2>sys
Enter system view, return to user view with Ctrl+Z.
[switch2]display vlan 2
VLAN State: 802.1q VLAN
VLAN ID: 2
VLAN Type: static
Route Interface: not configured
Tagged Ports:
GigabitEthernet0/22
Untagged Ports:
GigabitEthernet0/11
[switch2]display vlan 3
VLAN State: 802.1q VLAN
VLAN ID: 3
VLAN Type: static
Route Interface: not configured
Tagged Ports:
GigabitEthernet0/22
Untagged Ports:
GigabitEthernet0/21
可以发现配置成trunk端口 同时属于两个vlan
对于switch1也进行同样的配置
可以发现同一个vlan里的电脑能互相ping同,而不同vlan里的不能ping通
[switch2]vlan 2
[switch2-Vlan2]port g0/14
[switch2-Vlan2]vlan 3
[switch2-Vlan3]port g0/24
[switch2-Vlan3]display vlan 3
VLAN State: 802.1q VLAN
VLAN ID: 3
VLAN Type: static
Route Interface: not configured
Tagged Ports:
GigabitEthernet0/22
Untagged Ports:
GigabitEthernet0/21 GigabitEthernet0/24
[switch2-Vlan3]display vlan 2
VLAN State: 802.1q VLAN
VLAN ID: 2
VLAN Type: static
Route Interface: not configured
Tagged Ports:
GigabitEthernet0/22
Untagged Ports:
GigabitEthernet0/11 GigabitEthernet0/14
对switch1也做同样的配置
我在192.168.10.3里ping
7和我在vlan3里可以ping通,6和我不在一个vlan里ping不通。