Squid Block any Domain Name Accessing the Internet

Q. How do I block any website accessing the Internet using squid proxy server?

A. You can simply use squid ACL to block access to any web site. There are 3 steps:

#1. Create a text file with blocked domain name list such as baddomain1.com, mail.yahoo.com, gmail.com and so on

#2. Define Acl

#3. Restart squid

First, create a file called /etc/squid/blocked.domains.acl
# vi /etc/squid/blocked.domains.acl
Append domain names,

Save and close the file. Open squid.conf file:
# vi /etc/squid/squid.conf
Create acl called blockeddomain:
acl blockeddomain dstdomain "/etc/squid/blocked.domains.acl"
Deny http access, enter:
http_access deny blockeddomain
Close and save the file. Restart squid proxy server:
# /etc/init.d/squid restart

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Waloyce Oct 18, 2008 @ 12:38

    thanks for the tutorial it helped me a lot especially on blocking port and domain

    Also the tutorial are ellaborative even to new comes to linux

    Keep it up


    • vinay Apr 9, 2012 @ 13:09

      Squid Block any Domain Name Accessing the Internet

  • Sputnik Aug 25, 2009 @ 3:54

    does this resolution given works with LINUX SUSE 11.1?
    I made the necessary changes but still does not work


  • Vivek Sep 20, 2009 @ 12:48

    explained well to understand at the first look, thank you.

  • Vivek Oct 15, 2009 @ 4:49

    explained effectively ….Thank you so much…..

  • manan Feb 27, 2010 @ 19:33

    this is not working at all for me ,I have rhel5server ,still clients able to access the sites .

  • vooo Mar 14, 2010 @ 8:16

    Boomer this cannot do urls or wildcard just full domain names …

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz