配置准备数据:
设备名称 | IP地址 | VLAN网关 | 接口 | VLAN |
---|---|---|---|---|
PC1 | 192.168.10.1 | 192.168.10.254 | H3C G3/1/1 | 10 |
PC2 | 192.168.20.1 | 192.168.20.254 | H3C G3/1/3 | 20 |
第1段:配置交换机的VLAN和VLAN端口
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]vlan 10
[H3C-vlan10]name YW
[H3C-vlan10]description YW Vlan
[H3C-vlan10]port GigabitEthernet 3/1/1
[H3C-vlan10]vlan 20
[H3C-vlan20]name OA
[H3C-vlan20]description OA Vlan
[H3C-vlan20]port GigabitEthernet 3/1/3
[H3C-vlan20]quit
[H3C]interface vlan-interface 10
[H3C-Vlan-interface10]
%Jan 1 13:25:49:567 2007 H3C IFNET/3/LINK_UPDOWN: Vlan-interface10 link status is UP.
%Jan 1 13:25:49:587 2007 H3C IFNET/5/LINEPROTO_UPDOWN: Line protocol on the interface Vlan-interface10 is UP.
[H3C-Vlan-interface10]description YW gateway
[H3C-Vlan-interface10]ip address 192.168.10.254 24
[H3C-Vlan-interface10]quit
[H3C]interface vlan-interface 20
[H3C-Vlan-interface20]
%Jan 1 13:27:27:703 2007 H3C IFNET/3/LINK_UPDOWN: Vlan-interface20 link status is UP.
%Jan 1 13:27:27:723 2007 H3C IFNET/5/LINEPROTO_UPDOWN: Line protocol on the interface Vlan-interface20 is UP.
[H3C-Vlan-interface20]description OA gateway
[H3C-Vlan-interface20]ip address 192.168.20.254 24
[H3C-Vlan-interface20]return
第2段:配置PC
配置PC1:将PC1的IP地址设置为192.168.10.1,子网掩码为255.255.255.0,默认网关为192.168.10.254。
配置PC2:将PC1的IP地址设置为192.168.20.1,子网掩码为255.255.255.0,默认网关为192.168.20.254。
PC1与PC2可相互ping通。
第3段:查看VLAN10和VLAN20的相关信息
H3C>display vlan 10
VLAN ID: 10
VLAN Type: static
Route Interface: configured
IP Address: 192.168.10.254
Subnet Mask: 255.255.255.0
Description: YW Vlan
Name: YW
Tagged Ports: none
Untagged Ports:
GigabitEthernet3/1/1
<H3C>display vlan 20
VLAN ID: 20
VLAN Type: static
Route Interface: configured
IP Address: 192.168.20.254
Subnet Mask: 255.255.255.0
Description: OA Vlan
Name: OA
Tagged Ports: none
Untagged Ports:
GigabitEthernet3/1/3
第4段:在H3C交换机上查看IP和路由的相关信息
<H3C>display interface vlan-interface 10
Vlan-interface10 current state: UP
Line protocol current state: UP
Description: YW gateway
The Maximum Transmit Unit is 1500
Internet Address is 192.168.10.254/24 Primary
IP Packet Frame Type: PKTFMT_ETHNT_2, Hardware Address: 0000-fc00-6505
IPv6 Packet Frame Type: PKTFMT_ETHNT_2, Hardware Address: 0000-fc00-6505
Last clearing of counters: Never
Last 300 seconds input rate: 0 bytes/sec, 0 bits/sec, 0 packets/sec
Last 300 seconds output rate: 0 bytes/sec, 0 bits/sec, 0 packets/sec
0 packets input, 0 bytes, 0 drops
0 packets output, 0 bytes, 0 drops
<H3C>display ip interface brief
*down: administratively down
(s): spoofing
Interface Physical Protocol IP Address Description
M-Ethernet0/0/0 down down unassigned M-Etherne...
Vlan-interface1 up up unassigned Vlan-inte...
Vlan-interface10 up up 192.168.10.254 YW gateway
Vlan-interface20 up up 192.168.20.254 OA gateway
<H3C>display ip routing-table
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost NextHop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.10.0/24 Direct 0 0 192.168.10.254 Vlan10
192.168.10.254/32 Direct 0 0 127.0.0.1 InLoop0
192.168.20.0/24 Direct 0 0 192.168.20.254 Vlan20
192.168.20.254/32 Direct 0 0 127.0.0.1 InLoop0
(1) vlan vlan-id——在交换机上创建VLAN,并进入VLAN视图。
默认VLAN1。VLAN1不能创建也不能删除。VLAN ID的取值范围为1~4094。
也可以用 vlan { vlan-id1 [ to vlan-id2 ] | all } 来批量创建VLAN。
(2) name text——在VLAN视图下,配置当前VLAN的名称。
默认情况下,VLAN的名称为该VLAN的VLAN ID。
(3) description text——在VLAN视图下,配置VLAN的描述信息。
默认情况下,VLAN的描述信息为该VLAN的VLAN ID。
(4) interface vlan-interface vlan-interface-id——在交换机上创建VLAN接口,并进入VLAN接口视图。
(5) ip address ip-address { mask | mask-length }——配置VLAN接口的IP地址信息。
(6) display vlan vlan-id 命令显示VLAN的相关信息。
VLAN Type:有两种VLAN类型,static表示静态VLAN,dynamic表示动态VLAN。
Route interface:如果在交换机上创建了对应VLAN的接口,显示configured;如果没有创建对应VLAN接口,显示为not configured。
IP Address: 为VLAN接口的主IP地址。
Subnet Mask: 为VLAN接口的子网掩码。
Tagged Ports: 表示该VLAN报文从那些端口发送时需要携带Tag标记。
Untagged Ports: 表示该VLAN报文从那些端口发送时不需要携带Tag标记。
(8) display interface vlan-interface 命令显示VLAN接口的相关信息。
在此命令中,能够看到VLAN接口的以下信息。
- 物理状态和链路状态。
- 接口的描述信息。
- 接口的最大传输单元(MTU)。
- 接口的IP地址信息。
- 接口发送的帧格式。
- 接口的MAC地址。
- 最近5分钟内输入和输出的报文的速率。
- 接口输入和输出报文的总数。