If you have been requested to implement an internet access solution and you are passionate about OpenSource and GNU/Linux you are going to love this tutorial, we are going to do so by implementen a squid proxy server on Centos/REHL 7.

Must of you will be thinking about implementing a firewall solution, but keep in mind that firewalls are an amazing way to keep your internet safe and under control, but in some cases, they are very expensive and hard to manage (there are OpenSource firewalls as well), but if you are thinking about a little environment or would like to experiment some there is nothing better then using a Proxy Server.

Important: Firewalls and Proxy Servers are not equaled but have some features that share in common like allowing/restricting internet access which is what we are going to today without squid server.

This will be running on a CENTOS/RHEL 7 VM with minimum specs.

Make sure to have your server up-to-date by running

Next, we need to install Squid Proxy by running the following command:

Once your Squid has been successfully installed you can go ahead and start the program immediately

Do not forget to enable the squid service in order to start automatically at boot.

It is important to check on the Squid status just to make sure that everything is working fine.

You will see a pretty similar output like this:

If you are now to Squid you might want to have a look at the squid options by running:

and you will get:

for example:

Time to configure Squid

You can use whatever text editor you feel more comfortable, I like vi/vim, we need to modify the global configuration file /etc/squid/squid.conf

Do not get overwhelmed by the amount of information, this is just the default configuration file that will be working on in order to configure the proxy server.

How to allow a range of IP addresses to access the Internet through your proxy server

It is just as simple as adding a new ACL entry, Squid supports CIDR notation which makes the job more simple, for example, if you want to allow a range of IPs from to then you will need to add the following entry:

Your acl list will be looking like this:

Save your changes and move forward to restart the squid service.

Important: You just can reload in order for the service to read the global configuration file, using reload won’t restart the service.


Before we start using our proxy server we must consider that Squid only allows a few ports as “Safe ports” in order to allow connections through, here are the list of default allowed ports:

If you need any other port in specific that is not listed in your squid global configuration file feel free to add it otherwise your client won’t be able to connect to the internet through you Proxy Server.

Restart or reload your squid after performing any changes.

If you want to restrict access to several websites this can be easily done vi creating a new file called blocked_sites under /etc/squid

Here are some websites, for example, we wish to block (we actually do not want to block these but it is for educational purposes)

Save the file and open the /etc/squid/squid.conf in order to add the new rule.

Enter the following lines under acl and http_access lists

If you feel the need of changing the Squid default port, you just need to modify:

There is nothing else to say at this moment if you need to go a little bit more in deep about Squid go and check out their website http://www.squid-cache.org/ their documentation is pretty good.

Hope you enjoyed this tutorial and do not forget to share it.