TransWikia.com

squid : Block destination Subnet or IP addresses

Server Fault Asked by Bhalu on November 7, 2021

I have read many tutorial and official documentation, but the suggested method is not working for me.

I have set up a squid proxy(Squid Cache: Version 4.10, ubuntu 18.04.4 LTS) in my organization, and it works well for my use case. I have come across two issues but will focus one at a time.

Users can reach out to the Internet using a proxy, but from the logs, I see that Internal LAN IPs are accessed via web proxy. I want to restrict the users to use the Internet, not internal LAN IPs. On web proxies I have set the rule, neither of it works.

acl restricted_destination_subnetworks dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl restricted_destination_IP dst 10.50.21.135

http_access deny restricted_destination_IP http_access deny restricted_destination_subnetworks

Testing – From server, 10.50.40.18, I run below command, I get 200 OK, and I can see the log at web proxy as 200/TCP_MISS.

curl -s -o /dev/null -I -w "%{http_code} n" -k http://10.50.21.135:8585 200

Ideally, my curl request should be blocked, but in this scenario its not.

Can anyone correct me if I have done something wrong?

Full config

acl allowed_subnetworks src "/etc/squid/allowed_subnetworks_list.txt"

acl restricted_destination_subnetworks dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16  
acl restricted_destination_IP dst 10.50.21.135

acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump splice all
acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
acl localnet src fc00::/7           # RFC 4193 local private network range
acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT
    http_access allow allowed_subnetworks
    http_access deny restricted_destination_IP
    http_access deny restricted_destination_subnetworks 
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
 http_access allow localhost
  http_access deny all
http_port 3128 ssl-bump
cache_dir ufs /var/spool/squid 3000 16 256
coredump_dir /var/spool/squid
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|?) 0 0%  0
refresh_pattern .       0   20% 4320

Thanks

One Answer

The order of your http_access lines is wrong. SecurityPitfalls

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow allowed_subnetworks
http_access deny restricted_destination_IP
http_access deny restricted_destination_subnetworks 

#
# INSERT YOUR OWN RULE(S) BEFORE THESE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow localhost
http_access deny all

Answered by Gerard H. Pille on November 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP