VLAN间的单向通信established命令

2026-05-07
实验目的: 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。