實驗目的: VLAN間的單向通信
實驗描述: 本實驗環境中在一臺三層交換機上有三個VLAN,分別爲VLAN40,VLAN20,VLAN10。
要求:VLAN40內的主機可以共享VLAN10內主機上的共享文件夾,但VLAN10內的主機不可以訪問VLAN40。
sw#show run
!
version 12.3
!
hostname sw
ip subnet-zero
!
!
ip cef
!
!
no ip domain lookup
!
interface FastEthernet0/0
switchport access vlan 40
no ip address
!
interface FastEthernet0/1
switchport access vlan 10
no ip address
!
interface FastEthernet0/2
switchport access vlan 20
no ip address
!
interface Vlan10
ip address 1.1.1.1 255.0.0.0
!
interface Vlan20
ip address 2.2.2.1 255.0.0.0
!
!
interface Vlan40
ip address 4.4.4.1 255.0.0.0
ip access-group vlan40tovlan10 out
!
ip http server
ip classless
!
!
!
ip access-list extended vlan40tovlan10
permit tcp 1.0.0.0 0.255.255.255 4.0.0.0 0.255.255.255 established
permit icmp 1.0.0.0 0.255.255.255 4.0.0.0 0.255.255.255 echo-reply
!
!
!
control-plane
!
!
line con 0
exec-timeout 0 0
logging synchronous
line vty 0 4
login
transport preferred all
transport input all
transport output all
!
End
註明:ACL也可以用在接口VLAN10 的IN方向上,效果也一樣。
說明:假如主機A在vlan10中,主機B在VLAN40,當B訪問A時(通過TCP協議),在端口VLAN40的入方向和端口VLAN10的出方向上都沒有應用ACL,所以流量可以通過;然後從A需要返回給B一個流量,“permit tcp 1.0.0.0 0.255.255.255 4.0.0.0 0.255.255.255 established”這條命令就是用來識別這個返回的流量的,因爲是允許,所以可以通過,也就是說B可以通過TCP協議如TELNET連接A。但如果是A主動發起一個連接請求,這個流量需要從VLAN10端口進入,而在VLAN10端口應用了訪問控制列表,並且沒有這樣的允許條目,所以這個流量不被允許通過,也就是說B不可以通過TCP協議訪問A。