用4臺PC(pc多和少,原理是一樣的,所以這裏我只用了4臺pc),華爲路由器(R2621)、交換機(S3026e)各一臺,組建一VLAN,實現虛擬網和物理網之間的連接。實現防火牆策略,和訪問控制(ACL)。
方案說明:
四臺PC的IP地址、掩碼如下列表:
P1 192.168.1.1 255.255.255.0 網關IP 爲192.168.1.5
P2 192.168.1.2 255.255.255.0 網關IP 爲192.168.1.5
P3 192.168.1.3 255.255.255.0 網關IP 爲192.168.1.6
P4 192.168.1.4 255.255.255.0 網關IP 爲192.168.1.6
路由器上Ethernet0的IP 爲192.168.1.5
Ethernet1的IP 爲192.168.1.6
firewall 設置默認爲deny
實施命令列表:
交換機上設置,劃分VLAN:
<Quidway>sys
//切換到系統視圖
[Quidway]vlan enable
[Quidway]vlan 2
[Quidway-vlan2]port e0/1 to e0/8
[Quidway-vlan2]quit
//默認所有端口都屬於VLAN1,指定交換機的e0/1 到e0/8八個端口屬於VLAN2
[Quidway]vlan 3
[Quidway-vlan3]port e0/9 to e0/16
[Quidway-vlan3]quit
//指定交換機的e0/9 到e0/16八個端口屬於VLAN3
[Quidway]dis vlan all
[Quidway]dis cu
路由器上設置,實現訪問控制:
[Router]interface ethernet 0
[Router-Ethernet0]ip address 192.168.1.5 255.255.255.0
[Router-Ethernet0]quit
//指定ethernet 0的ip
[Router]interface ethernet 1
[Router-Ethernet1]ip address 192.168.1.6 255.255.255.0
[Router-Ethernet1]quit
//開啓firewall,並將默認設置爲deny
[Router]fire enable
[Router]fire default deny
//允許192.168.1.1訪問192.168.1.3
//firewall策略可根據需要再進行添加
[Router]acl 101
[Router-acl-101]rule permit ip source 192.168.1.1 255.255.255.0 destination 192.168.1.3 255.255.255.0
[Router-acl-101]quit
//啓用101規則
[Router-Ethernet0]fire pa 101
[Router-Ethernet0]quit
[Router-Ethernet1]fire pa 101
[Router-Ethernet1]quit
---------------------------------------------------------------------------------------------------------------------------------------------------
H3C E126A是一款專爲教育城域網(或校園網)設計的二層智能交換機,作業接入層或匯聚層使用。本篇文章主要介紹基於端口的Vlan的配置。
一、創建Vlan
在系統(全局)視圖下輸入命令:vlan vlanid
[Swicth126A]vlan 20 //說明:創建ID爲20的vlan
[Swicth126A-vlan20]name Chinese //vlan的名稱爲Chinese
[Swicth126A-vlan20]description Chinese Teacher //vlan的描述
[Swicth126A-vlan20]quit
二、把交換機的端端口劃分到相應的Vlan中
[Swicth126A]interface ethernet1/0/2 //進入端口模式
[Swicth126A-Ethernet1/0/2]port link-type access //設置端口的類型爲access
[Swicth126A-Ethernet1/0/2]port access vlan 20 //把當前端口劃到vlan 20
[Swicth126A-Ethernet1/0/2]
[Swicth126A]vlan 10
[Swicth126A-vlan10]port ethernet1/0/3 to ethernet1/0/5 //把以及網端口1/0/3到1/0/5劃到vlan10
[Swicth126A-vlan10]quit
三、爲Vlan配置IP
[Swicth126A]management-vlan 20 //管理vlan20
[Swicth126A]interface vlan-interface 20 //進入vlan 20接口模式
[Swicth126A-Vlan-interface20]
%Apr 2 00:33:29:321 2000 Swicth126A L2INF/5/VLANIF LINK STATUS CHANGE:- 1 -
Vlan-interface20 is UP
[Swicth126A-Vlan-interface20]ip address 192.168.0.1 255.255.255.0 //爲vlan20接口配置IP地址
[Swicth126A-Vlan-interface20]
%Apr 2 00:33:42:092 2000 Swicth126A IFNET/5/UPDOWN:- 1 -Line protocol on the in
terface Vlan-interface20 is UP
[Swicth126A-Vlan-interface20]quit
[Swicth126A]
[Swicth126A]undo interface vlan-interface 20 //刪除vlan 20管理接口
[Swicth126A]
%Apr 2 00:40:45:273 2000 Swicth126A L2INF/5/VLANIF LINK STATUS CHANGE:- 1 -
Vlan-interface20 is DOWN
%Apr 2 00:40:45:375 2000 Swicth126A IFNET/5/UPDOWN:- 1 -Line protocol on the in
terface Vlan-interface20 is DOWN
[Swicth126A]management-vlan 10
[Swicth126A]interface vlan-interface 10 //進入vlan 10接口模式
[Swicth126A-Vlan-interface10]
%Apr 2 00:41:11:634 2000 Swicth126A L2INF/5/VLANIF LINK STATUS CHANGE:- 1 -
Vlan-interface10 is UP
[Swicth126A-Vlan-interface10]ip address 192.168.1.1 255.255.255.0 //設置IP地址
[Swicth126A-Vlan-interface10]
%Apr 2 00:41:23:241 2000 Swicth126A IFNET/5/UPDOWN:- 1 -Line protocol on the in
terface Vlan-interface10 is UP
[Swicth126A-Vlan-interface10]quit
[Swicth126A]
四、查看Vlan信息
[Swicth126A][Swicth126A]display vlan 20
VLAN ID: 20
VLAN Type: static
Route Interface: not configured
Description: Chinese Teacher
Name: Chinese
Tagged Ports: none
Untagged Ports:
Ethernet1/0/2 Ethernet1/0/6 Ethernet1/0/7
Ethernet1/0/8 Ethernet1/0/9 Ethernet1/0/10