01過流政策實作VLAN間三層隔離
1.1 組網需求
如圖 1 所示,為了通信的安全性,某公司将訪客、員工、伺服器分别劃分到VLAN10、VLAN20、VLAN30中。公司希望:
- 員工、伺服器主機、訪客均能通路Internet。
- 訪客隻能通路Internet,不能與其他任何VLAN的使用者通信。
- 員工A可以通路伺服器區的所有資源,但其他員工隻能通路伺服器A的21端口(FTP服務)。
圖 1 配置通過流政策實作VLAN間三層隔離組網圖
1.2 配置思路
可采用如下思路配置通過流政策實作VLAN間互訪控制:
- 配置VLAN并将各接口加入VLAN,使員工、伺服器、訪客間二層隔離。
- 配置VLANIF接口及其IP位址,使員工、伺服器、訪客間可三層互通。
- 配置上行路由,使員工、伺服器、訪客均可通過Switch通路Internet。
- 配置并應用流政策,使員工A可以通路伺服器區的所有資源,其他員工隻能通路伺服器A的21端口,且隻允許員工通路伺服器;使訪客隻能通路Internet。
1.3 操作步驟
【1】配置VLAN并将各接口加入VLAN,使員工、伺服器、訪客間二層隔離
# 在Switch_1上建立VLAN10,并将接口GE1/0/1以Untagged方式加入VLAN10,接口GE1/0/2以Tagged方式加入VLAN10。Switch_2和Switch_3的配置與Switch_1類似,不再贅述。(詳看文章後面的配置檔案)
<HUAWEI> system-view
[HUAWEI] sysname Switch_1
[Switch_1] vlan batch 10
[Switch_1] interface gigabitethernet 1/0/1
[Switch_1-GigabitEthernet1/0/1] port link-type access
[Switch_1-GigabitEthernet1/0/1] port default vlan 10
[Switch_1-GigabitEthernet1/0/1] quit
[Switch_1] interface gigabitethernet 1/0/2
[Switch_1-GigabitEthernet1/0/2] port link-type trunk
[Switch_1-GigabitEthernet1/0/2] port trunk allow-pass vlan 10
[Switch_1-GigabitEthernet1/0/2] quit
# 在Switch_4上建立VLAN10、VLAN20、VLAN30、VLAN100,并配置接口GE1/0/1~GE1/0/4分别以Tagged方式加入VLAN10、VLAN20、VLAN30、VLAN100。
<HUAWEI> system-view
[HUAWEI] sysname Switch_4
[Switch_4] vlan batch 10 20 30 100
[Switch_4] interface gigabitethernet 1/0/1
[Switch_4-GigabitEthernet1/0/1] port link-type trunk
[Switch_4-GigabitEthernet1/0/1] port trunk allow-pass vlan 10
[Switch_4-GigabitEthernet1/0/1] quit
[Switch_4] interface gigabitethernet 1/0/2
[Switch_4-GigabitEthernet1/0/2] port link-type trunk
[Switch_4-GigabitEthernet1/0/2] port trunk allow-pass vlan 20
[Switch_4-GigabitEthernet1/0/2] quit
[Switch_4] interface gigabitethernet 1/0/3
[Switch_4-GigabitEthernet1/0/3] port link-type trunk
[Switch_4-GigabitEthernet1/0/3] port trunk allow-pass vlan 30
[Switch_4-GigabitEthernet1/0/3] quit
[Switch_4] interface gigabitethernet 1/0/4
[Switch_4-GigabitEthernet1/0/4] port link-type trunk
[Switch_4-GigabitEthernet1/0/4] port trunk allow-pass vlan 100
[Switch_4-GigabitEthernet1/0/4] quit
【2】配置VLANIF接口及其IP位址,使員工、伺服器、訪客間可以三層互通
# 在Switch_4上建立VLANIF10、VLANIF20、VLANIF30、VLANIF100,并分别配置其IP位址為10.1.1.1/24、10.1.2.1/24、10.1.3.1/24、10.1.100.1/24。
[Switch_4] interface vlanif 10
[Switch_4-Vlanif10] ip address 10.1.1.1 24
[Switch_4-Vlanif10] quit
[Switch_4] interface vlanif 20
[Switch_4-Vlanif20] ip address 10.1.2.1 24
[Switch_4-Vlanif20] quit
[Switch_4] interface vlanif 30
[Switch_4-Vlanif30] ip address 10.1.3.1 24
[Switch_4-Vlanif30] quit
[Switch_4] interface vlanif 100
[Switch_4-Vlanif100] ip address 10.1.100.1 24
[Switch_4-Vlanif100] quit
【3】配置上行路由,使員工、伺服器、訪客均可通過Switch通路Internet。
# 在Switch_4上配置OSPF基本功能,釋出使用者網段以及Switch_4與Router之間的網際網路段。
[Switch_4] ospf
[Switch_4-ospf-1] area 0
[Switch_4-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[Switch_4-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255
[Switch_4-ospf-1-area-0.0.0.0] network 10.1.3.0 0.0.0.255
[Switch_4-ospf-1-area-0.0.0.0] network 10.1.100.0 0.0.0.255
[Switch_4-ospf-1-area-0.0.0.0] quit
[Switch_4-ospf-1] quit
Router上需要進行如下配置:
将連接配接Switch的接口以Tagged方式加入VLAN100,并指定VLANIF100的IP位址與10.1.100.1在同一網段。
配置OSPF基本功能,并釋出Switch與Router之間的網際網路段。
【4】配置并應用流政策,控制員工、訪客、伺服器之間的通路
A、通過ACL定義每個流
# 在Switch_4上配置ACL 3000,禁止訪客通路員工區和伺服器區。
[Switch_4] acl 3000
[Switch_4-acl-adv-3000] rule deny ip destination 10.1.2.1 0.0.0.255
[Switch_4-acl-adv-3000] rule deny ip destination 10.1.3.1 0.0.0.255
[Switch_4-acl-adv-3000] quit
# 在Switch_4上配置ACL 3001,使員工A可以通路伺服器區的所有資源,其他員工隻能通路伺服器A的21端口。
[Switch_4] acl 3001
[Switch_4-acl-adv-3001] rule permit ip source 10.1.2.2 0 destination 10.1.3.1 0.0.0.255
[Switch_4-acl-adv-3001] rule permit tcp destination 10.1.3.2 0 destination-port eq 21
[Switch_4-acl-adv-3001] rule deny ip destination 10.1.3.1 0.0.0.255
[Switch_4-acl-adv-3001] quit
B、配置流分類,區分不同的流
# 在Switch_4上建立流分類c_custom、c_staff,并分别配置比對規則3000、3001。
[Switch_4] traffic classifier c_custom
[Switch_4-classifier-c_custom] if-match acl 3000
[Switch_4-classifier-c_custom] quit
[Switch_4] traffic classifier c_staff
[Switch_4-classifier-c_staff] if-match acl 3001
[Switch_4-classifier-c_staff] quit
C、配置流行為,指定流動作
# 在Switch_4上建立流行為b1,并配置允許動作。
[Switch_4] traffic behavior b1
[Switch_4-behavior-b1] permit
[Switch_4-behavior-b1] quit
D、配置流政策,關聯流分類和流行為
# 在Switch_4上建立流政策p_custom、p_staff,并分别将流分類c_custom、c_staff與流行為b1關聯。
[Switch_4] traffic policy p_custom
[Switch_4-trafficpolicy-p_custom] classifier c_custom behavior b1
[Switch_4-trafficpolicy-p_custom] quit
[Switch_4] traffic policy p_staff
[Switch_4-trafficpolicy-p_staff] classifier c_staff behavior b1
[Switch_4-trafficpolicy-p_staff] quit
E、應用流政策,實作員工、訪客、伺服器之間的通路控制
# 在Switch_4上,分别在VLAN10、VLAN20的入方向應用流政策p_custom、p_staff。
[Switch_4] vlan 10
[Switch_4-vlan10] traffic-policy p_custom inbound
[Switch_4-vlan10] quit
[Switch_4] vlan 20
[Switch_4-vlan20] traffic-policy p_staff inbound
[Switch_4-vlan20] quit
【5】驗證配置結果
配置訪客A的IP位址為10.1.1.2/24,預設網關為VLANIF10接口的IP位址10.1.1.1;配置員工A的IP位址為10.1.2.2/24,預設網關為VLANIF20接口的從IP位址10.1.2.1;配置員工B的IP位址為10.1.2.3/24,預設網關為VLANIF20接口的從IP位址10.1.2.1;配置伺服器A的IP位址為10.1.3.2/24,預設網關為VLANIF30接口的從IP位址10.1.3.1。
配置完成後:
- 訪客A不能Ping通員工A、伺服器A;員工A和伺服器A不能Ping通訪客A。
- 員工A可以Ping通伺服器A,即可以使用伺服器A的FTP服務,也可以使用伺服器A的。
- 員工B可以Ping不通伺服器A,隻能使用伺服器A的FTP服務。
- 訪客、員工A、員工B、伺服器A均可以Ping通Router連接配接Switch_4的接口的IP位址10.1.100.2/24,也就都可以通路Internet。
1.4 配置檔案
Switch_1的配置檔案
#
sysname Switch_1
#
vlan batch 10
#
interface GigabitEthernet1/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk allow-pass vlan 10
#
return
Switch_2的配置檔案
#
sysname Switch_2
#
vlan batch 20
#
interface GigabitEthernet1/0/1
port link-type access
port default vlan 20
#
interface GigabitEthernet1/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet1/0/3
port link-type trunk
port trunk allow-pass vlan 20
#
return
Switch_3的配置檔案
#
sysname Switch_3
#
vlan batch 30
#
interface GigabitEthernet1/0/1
port link-type access
port default vlan 30
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk allow-pass vlan 30
#
return
Switch_4的配置檔案
#
sysname Switch_4
#
vlan batch 10 20 30 100
#
acl number 3000
rule 5 deny ip destination 10.1.2.0 0.0.0.255
rule 10 deny ip destination 10.1.3.0 0.0.0.255
acl number 3001
rule 5 permit tcp destination 10.1.3.2 0 destination-port eq ftp
rule 10 permit ip source 10.1.2.2 0 destination 10.1.3.0 0.0.0.255
rule 15 deny ip destination 10.1.3.0 0.0.0.255
#
traffic classifier c_custom operator or precedence 5
if-match acl 3000
traffic classifier c_staff operator or precedence 10
if-match acl 3001
#
traffic behavior b1
permit
#
traffic policy p_custom match-order config
classifier c_custom behavior b1
traffic policy p_staff match-order config
classifier c_staff behavior b1
#
vlan 10
traffic-policy p_custom inbound
vlan 20
traffic-policy p_staff inbound
#
interface Vlanif10
ip address 10.1.1.1 255.255.255.0
#
interface Vlanif20
ip address 10.1.2.1 255.255.255.0
#
interface Vlanif30
ip address 10.1.3.1 255.255.255.0
#
interface Vlanif100
ip address 10.1.100.1 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type trunk
port trunk allow-pass vlan 10
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk allow-pass vlan 20
#
interface GigabitEthernet1/0/3
port link-type trunk
port trunk allow-pass vlan 30
#
interface GigabitEthernet1/0/4
port link-type trunk
port trunk allow-pass vlan 100
#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 10.1.2.0 0.0.0.255
network 10.1.3.0 0.0.0.255
network 10.1.100.0 0.0.0.255
#
return