在“router-on-a-stick”中创建访问列表

网络工程 思科 局域网 acl
2022-02-24 18:13:37

我正在尝试在“router-on-a-stick”中创建一个访问,它只允许 VLAN 62 与另一个 VLAN 上的服务器通信,其他 VLAN 中的其他主机都不能访问 VLAN 62。要清楚,我的VLAN 62 是网络摄像头的 VLAN,我的服务器是注册服务器。我尝试过标准和扩展 acl,但它不起作用。谁能帮我吗 ?
ps:我也有一个问题。在标准 acl 中,“拒绝部分”是否必须位于“允许部分”之上。对不起,我的英语不好。

version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
ip dhcp pool 61
 network 192.168.6.64 255.255.255.192
 default-router 192.168.6.65
ip dhcp pool 62
 network 192.168.6.128 255.255.255.192
 default-router 192.168.6.129
ip dhcp pool 2
 network 192.168.6.0 255.255.255.192
 default-router 192.168.6.1
!
!
!
ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO1941/K9 sn FTX1524S9UZ
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface GigabitEthernet0/0.2
 encapsulation dot1Q 2
 ip address 192.168.6.1 255.255.255.192
!
interface GigabitEthernet0/0.61
 encapsulation dot1Q 61
 ip address 192.168.6.65 255.255.255.192
!
interface GigabitEthernet0/0.62  ! *** I want this VLAN to be completely separate from others except for VLAN 2 ***
 encapsulation dot1Q 62
 ip address 192.168.6.129 255.255.255.192
 ip access-group 162 in
 ip access-group 162 out
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/1/0
 no ip address
 clock rate 2000000
 shutdown
!
interface Serial0/1/1
 ip address 192.168.67.3 255.255.255.0
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 network 192.168.6.0
 network 192.168.67.0
!
ip classless
!
ip flow-export version 9
!
!
access-list 162 permit ip 192.168.6.128 0.0.0.64 192.168.6.0 0.0.0.64
access-list 162 deny ip any any
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end
2个回答

编辑:

允许 VLAN 62 上的设备与 VLAN2 通信,仅此而已。

access-list 162 permit ip 192.168.6.128 0.0.0.63 192.168.6.0 0.0.0.63
access-list 162 permit udp any any eq bootps
access-list 163 permit ip 192.168.6.0 0.0.0.63 192.168.6.128 0.0.0.63
access-list 163 permit udp any any eq bootpc
interface GigabitEthernet0/0.62
ip access-group 162 in
ip access-group 163 out

请注意 ACL 中的通配符掩码 0.0.0.63。此外,“deny any any”隐含在每个 ACL 的末尾。如果你明确说明它,它会在最后。

我假设您只希望 VLAN 62 中的主机访问 VLAN 2 中的主机(反之亦然),而不是其他(没有 Internet ...):

access-list 162 permit ip 192.168.6.128 0.0.0.63 192.168.6.0 0.0.0.63
access-list 162 permit udp any any eq bootps
access-list 162 deny   ip any any log

access-list 163 permit ip 192.168.6.0 0.0.0.63 192.168.6.128 0.0.0.63
access-list 163 deny   ip any any log

interface FastEthernet0/0.62
 encapsulation dot1Q 62
 ip address 192.168.6.129 255.255.255.192
 ip access-group 162 in
 ip access-group 163 out

请注意,该规则access-list 162 permit udp any any eq bootps是让 VLAN 62 中的主机到达此路由器(作为 DHCP 服务器)以获取 DHCP IP 地址。在此设置中,我们不需要在access-list 163.

最后但并非最不重要的一点是,最佳实践是:始终在 ACL 末尾放置一个deny ip any any带有选项的显式规则,以验证哪些内容被阻止/拒绝。log然后,您可以相应地修改 ACL。

我希望它是有帮助的,你可以解决这个问题。