为什么我的简单标准 ACL 出站不会阻止 VLAN 的 SVI 的网关流量/ping?

网络工程 思科 访问控制
2022-02-23 05:30:30

我正在使用路由器/交换机Cisco C1111-8p with IOS XE 16.8

我有 3 个 VLAN:

  • 1:原生/管理
  • 20:开发
  • 50:客人

我想阻止客人/VLAN50 与互联网以外的任何人进行通信。

为此,我使用 VLAN50 的子网创建了访问列表标准。我将此 ACL 应用于 VLAN1/native/management 和 VLAN20/dev outbound 的 SVI(从路由器的角度来看)。

conf t
access-list 10 deny 192.168.50.0 0.0.0.255
access-list 10 permit any
end

# VLAN 1 DEFAULT NATIVE
conf t
vlan 1
interface vlan 1
ip address 192.168.0.1 255.255.255.0
ip nat inside
ip access-group 10 out
end

# VLAN 20
conf t
vlan 20
name Dev
interface vlan 20
ip address 192.168.20.1 255.255.255.0
ip nat inside
ip access-group 10 out
end

连接到 VLAN1 本机的设备的 Ping 被过滤

$ ping 192.168.0.200
PING 192.168.0.200 (192.168.0.200) 56(84) bytes of data.
From 192.168.50.1 icmp_seq=1 Packet filtered
From 192.168.50.1 icmp_seq=2 Packet filtered
From 192.168.50.1 icmp_seq=3 Packet filtered

尽管如此,我仍然可以 ping 通 VLAN1 和 VLAN20 网关192.168.0.1以及192.168.20.1.

$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=255 time=17.9 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=255 time=30.4 ms

$ ping 192.168.20.1
PING 192.168.20.1 (192.168.20.1) 56(84) bytes of data.
64 bytes from 192.168.20.1: icmp_seq=1 ttl=255 time=2.73 ms
64 bytes from 192.168.20.1: icmp_seq=2 ttl=255 time=23.7 ms

为什么?

我正在使用无线接入点对每个不同的 VLAN 和 VLAN1 作为本地 VLAN 使用 SSID 进行测试。在使用扩展之前,我想先使用 ACL 标准进行测试。

完整配置供参考(我不写 DHCP 部分):

vlan internal allocation policy ascending
!         
!         
!         
!         
!         
!         
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!         
interface GigabitEthernet0/0/0
 description WAN
 ip address x.x.x.x 255.255.255.252
 ip nat outside
 negotiation auto
!         
interface GigabitEthernet0/0/1
 no ip address
 shutdown 
 negotiation auto
!         
interface GigabitEthernet0/1/0
 switchport mode trunk
 switchport nonegotiate
!         
interface GigabitEthernet0/1/1
 shutdown 
!         
interface GigabitEthernet0/1/2
 switchport access vlan 10
 switchport mode access
!         
interface GigabitEthernet0/1/3
 switchport access vlan 20
 switchport mode access
!         
interface GigabitEthernet0/1/4
 shutdown 
!         
interface GigabitEthernet0/1/5
 shutdown 
!         
interface GigabitEthernet0/1/6
 switchport mode access
!         
interface GigabitEthernet0/1/7
 switchport mode access
!         
interface Vlan1
 ip address 192.168.0.1 255.255.255.0
 ip nat inside
 ip access-group 10 in
!         
interface Vlan10
 ip address 192.168.10.1 255.255.255.0
 ip nat inside
 ip access-group 10 out
!         
interface Vlan20
 ip address 192.168.20.1 255.255.255.0
 ip nat inside
 ip access-group 10 out
!         
interface Vlan50
 ip address 192.168.50.1 255.255.255.0
 ip nat inside
!         
ip nat inside source list NAT interface GigabitEthernet0/0/0 overload
ip forward-protocol nd
no ip http server
ip http secure-server
ip dns server
ip route 0.0.0.0 0.0.0.0 x.x.x.x
!         
!         
ip access-list standard NAT
 permit 192.168.10.0 0.0.0.255
 permit 192.168.0.0 0.0.0.255
 permit 192.168.20.0 0.0.0.255
 permit 192.168.50.0 0.0.0.255
!         
access-list 10 deny   192.168.50.0 0.0.0.255
access-list 10 permit any
!         
!         
!         
!         
control-plane
!         
!         
line con 0
 transport input none
 stopbits 1
line vty 0 4
 login local
 transport input ssh
!         
wsma agent exec
!         
wsma agent config
!         
wsma agent filesys
!         
wsma agent notify
!         
!         
end
2个回答

您仍然可以 ping 路由器 IP,因为 ACL 仅适用于通过接口的流量,而不适用于接口本身。

好吧,如果您想按照描述进行操作,则必须这样做:

vlan 1 - 192.168.0.0/24

vlan 10 - 192.168.10.0/24

vlan 20 - 192.168.20.0/24

vlan 50 - 192.168.50.0/24

access-list 10 deny 192.168.50.0 0.0.0.255
access-list 10 permit any

access-list 20 deny 192.168.0.0 0.0.0.255
access-list 20 deny 192.168.10.0 0.0.0.255
access-list 20 deny 192.168.20.0 0.0.0.255
access-list 20 permit any

interface Vlan1
 ip address 192.168.0.1 255.255.255.0
 ip nat inside
 ip access-group 10 out

interface Vlan10
 ip address 192.168.10.1 255.255.255.0
 ip nat inside
 ip access-group 10 out

interface Vlan20
 ip address 192.168.20.1 255.255.255.0
 ip nat inside
 ip access-group 10 out

interface Vlan50
 ip address 192.168.50.1 255.255.255.0
 ip nat inside
 ip access-group 20 out

综上所述user56700,ACL 规则适用于通过的流量,而不是流向接口本身,因此也不会流向接口的网关。此外,由于我将 VLAN 与 SVI 一起使用,SVI 是路由器的内部组件,因此无法通过出站规则阻止内部生成的内容。我们需要在流量被路由之前阻止它。

要隔离整个 GUESTS VLAN 但允许 Internet,标准 ACL 是不够的。我们需要使用INBOUND规则。

通过对 VLAN50 接口使用名称扩展 ACL,我可以阻止所有到其他 VLAN 的流量,因为该规则应用于 INBOUND,基本上流量在到达任何内容之前都会被拒绝。

conf t
ip access-list extended GUESTSACL
deny ip any 192.168.0.0 0.0.0.255
deny ip any 192.168.10.0 0.0.0.255
deny ip any 192.168.20.0 0.0.0.255
permit ip any any
end
conf t
int vlan 50
ip access-group GUESTSACL in
end

Communication administratively filteredVLAN50 的网关将使用ICMP 消息回复每个 ICMP 回显。这会导致 CPU 使用率过高,并提示网络中被阻止的内容。

要停止发送此消息,我们需要no ip unreachables在界面中添加:

conf t
interface vlan 50
no ip unreachables
end