使用 ACL 隔离 Cisco 网络

网络工程 思科 acl ip
2022-02-25 13:24:53

我正在使用 Cisco 1841 路由器,并且配置了 2 个子接口。F0/1.10 和 1.20。

我想停止 VLAN 10 上的设备访问 VLAN 20,反之亦然。

VLAN 10 位于 10.10.10.1 和 VLAN 20 10.10.20.1

我已经配置了以下访问控制列表

access-list 19 deny 10.10.10.0 0.0.0.255
access-list 19 permit any

access-list 29 deny 10.10.20.0 0.0.0.255
access-list 29 permit any

并将它们应用到子接口的出站端

interface f0/1.10
ip access-group 29 out

interface f0/1.20
ip access-group 19 out

问题是我仍然可以通过网络 ping。

非常感谢任何帮助,如果您需要,完整配置如下。

谢谢,

完整配置:

service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip cef
!
!
ip dhcp use vrf connected
ip dhcp excluded-address 10.10.10.201 10.10.10.255
ip dhcp excluded-address 10.10.20.201 10.10.20.255
!
ip dhcp pool 10.10.10.0/24
 network 10.10.10.0 255.255.255.0
 default-router 10.10.10.1 
   dns-server 8.8.8.8 8.8.4.4 
!
ip dhcp pool 10.10.20.0/24
   network 10.10.20.0 255.255.255.0
   default-router 10.10.20.1 
   dns-server 8.8.8.8 8.8.4.4 
!
!
vpdn enable
!

!
interface FastEthernet0/0
 description Fibre WAN Interface
 no ip address
 ip broadcast-address 0.0.0.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 no ip mroute-cache
 duplex auto
 speed auto
 pppoe enable group global
 pppoe-client dial-pool-number 1
 no cdp enable
!
interface FastEthernet0/1
 description LAN Interface
 no ip address
 ip broadcast-address 10.10.10.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat inside
 no ip mroute-cache
 duplex auto
 speed auto
 no cdp enable
!
interface FastEthernet0/1.10
 encapsulation dot1Q 10
 ip address 10.10.10.1 255.255.255.0
 ip access-group 29 out
 ip nat inside
 no cdp enable
!
interface FastEthernet0/1.20
 encapsulation dot1Q 20
 ip address 10.10.20.1 255.255.255.0
 ip access-group 19 out
 ip nat inside
 no cdp enable
!
interface Serial0/0/0
 no ip address
 ip broadcast-address 0.0.0.0
 shutdown
 no fair-queue
 clock rate 2000000
!
interface Dialer1
 description ADSL WAN Dialer
 ip address negotiated
 no ip unreachables
 ip mtu 1492
 ip nat outside
 encapsulation ppp
 ip tcp adjust-mss 1452
 no ip mroute-cache
 dialer pool 1
 dialer-group 1
 no cdp enable
 ppp chap hostname bne001-indigointegrated@surfdsluk
 ppp chap password 0 T57Gfc09Hjd5SQw
 ppp ipcp route default
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
ip nat inside source list 10 interface Dialer1 overload
!
access-list 10 permit 10.10.10.0 0.0.0.255
access-list 10 permit 10.10.20.0 0.0.0.255
access-list 19 deny   10.10.10.0 0.0.0.255
access-list 19 permit any
access-list 20 permit 10.10.10.0 0.0.0.255
access-list 29 deny   10.10.20.0 0.0.0.255
access-list 29 permit any
dialer-list 1 protocol ip permit
no cdp run

control-plane

line con 0
line aux 0
line vty 0 4
 access-class 20 in
 login
!
scheduler allocate 20000 1000
end
2个回答

您使用的是标准访问列表,因此仅引用源地址。例如,从 VLAN 10 出去,你的源地址是 10.10.10.0,但它的访问列表有 10.10.20.0,它不会匹配,也不会按照你的想法做。

您需要扩展访问列表来指定目的地,这是与访问列表理念保持一致的一个选项。

access-list 119 extended deny ip any 10.10.10.0 0.0.0.255
access-list 119 extended permit ip any any
access-list 129 extender deny ip any 10.10.20.0 0.0.0.255
access-list 129 extended permit ip any any
  • 标准 IP ACL:1 到 99 和 1300 到 1999
  • 扩展 IP ACL:100 到 199 和 2000 到 2699

如果您需要接口之间的完全路由隔离,另一种选择是在您的软件支持的情况下使用VRF-lite 。

因此,首先 - 如果要求 ACL,则至少应首先引用 ACL。VRF 很棒,但如果您遇到 ACL 问题,则相当复杂 :)

我个人从未在“出”方向使用 ACL,因为在 IOS 的早期版本(11.x、12.0、12.1)中有很多异常、错误和通常必须调试的东西才能确保它按预期工作。

'generalnetworkerror' 给出的 ACL 是正确的,因为使用标准 ACL 在该场景中不起作用。但是,我会将它们应用于“入”方向,并完全摆脱“出”。所以:

interface FastEthernet0/1.10
 ip address 10.10.10.1 255.255.255.0
 no ip access-group 29 out
 ip access-group 129 in
!
interface FastEthernet0/1.20
 ip address 10.10.20.1 255.255.255.0
 no ip access-group 19 out
 ip access-group 119 in
! (for the completness sake, generalnetworkerror ACLs reproduced):
access-list 119 extended deny ip any 10.10.10.0 0.0.0.255
access-list 119 extended permit ip any any
access-list 129 extender deny ip any 10.10.20.0 0.0.0.255
access-list 129 extended permit ip any any

为了更好的衡量,我还要补充:

interface FastEthernet0/1.10
 ip verify unicast source reachable-via rx
interface FastEthernet0/1.20
 ip verify unicast source reachable-via rx