配置准備數據:
設備名稱 | 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分鍾內輸入和輸出的報文的速率。
- 接口輸入和輸出報文的總數。