使用 ACL 拒绝私有地址

网络工程 思科 纳特 acl 数据包跟踪器
2022-02-14 21:24:39

使用这个风景,我怎么能拒绝私有地址,但是在这种情况下,192.168.0.0/24网络出去而不使用公共地址?

只有在翻译后才允许流量,在本例中为 10.0.0.1 地址

拓扑

企业路由器

!
ip dhcp pool VLAN2
 network 192.168.0.0 255.255.255.192
 default-router 192.168.0.1
ip dhcp pool VLAN3
 network 192.168.0.64 255.255.255.224
 default-router 192.168.0.65
ip dhcp pool VLAN4
 network 192.168.0.96 255.255.255.248
 default-router 192.168.0.97
!
!
interface FastEthernet0/0
 no ip address
 ip nat inside
 duplex auto
 speed auto
!
interface FastEthernet0/0.2
 encapsulation dot1Q 2
 ip address 192.168.0.1 255.255.255.192
!
interface FastEthernet0/0.3
 encapsulation dot1Q 3
 ip address 192.168.0.65 255.255.255.224
!
interface FastEthernet0/0.4
 encapsulation dot1Q 4
 ip address 192.168.0.97 255.255.255.248
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0/0
 ip address 10.0.0.1 255.255.255.252
 ip nat outside
 clock rate 2000000
!
!
ip nat inside source list 100 interface Serial0/0/0 overload
ip classless
ip route 0.0.0.0 0.0.0.0 10.0.0.2 
!

忽略这一行“ip nat inside sourcer list 100..”我删除了一个 ACL..

2个回答

如果您试图阻止本地内部的设备到达 ISP 而没有先进行 NAT(从 192.168.0.x 更改为 10.0.0.x):创建一个 ACL,它允许所有非192.168.0.x,或者只允许10.0.0.x,应用到企业路由器的出接口。

这样的事情会阻止 192.168.0.x,但允许其他所有内容:

ip 访问列表标准 101

拒绝 192.168.0.0 0.0.0.255

允许任何

这将只允许 10.0.0.x 网络通过:

ip 访问列表标准 101

允许 10.0.0.0 0.0.0.255

拒绝任何

(您不需要输入“deny any”命令,因为 ACL 默认在末尾有一个明确的拒绝命令)

然后将其中之一应用到企业路由器的 S0/0/0 接口:

接口 S0/0/0

ip 访问组 101 出

注意事项:这是使用标准 ACL 而不是扩展 ACL,因为您只想根据源 IP 允许或拒绝。如果您想根据端口过滤或根据源和目标IP 允许/拒绝,您将使用和扩展 ACl。此外,由于这是一个标准 ACL,它被放置在尽可能靠近目的地的位置;这样你就不会用你想要阻止的东西过滤掉合法的流量。这意味着在这种情况下将其分配为 S0/0/0 端口上的传出。

将 NAT 语句放回去:

ip nat inside source list 100 interface Serial0/0/0 overload
access-list 100 permit ip 192.168.0.0 0.0.255.255 any