Easily implement Internet filtering in Linux

Source: Internet
Author: User
Tags squid proxy


At present, many schools have built campus networks and connected to the Internet, but there are a lot of bad information on the Internet. How can we filter out websites to prevent the impact of unhealthy websites on students? Based on the principle of zero cost and high efficiency, let's talk about how to implement Internet filtering in free Linux.

Set Proxy Server

The campus network accesses the Internet through Linux and uses Squid to build proxy servers on the gateway.

First, install Linux. I use RedHat Linux 7.2, which is easy to install and use. When installing RedHat Linux 7.2, Squid has been installed at the same time. You only need to configure it.

After RedHat Linux 7.2 is installed, Apache is not running by default. Therefore, you should enable Squid to ensure that the Squid Proxy Server works properly. Modify the/etc/squid. conf configuration file.

Http_port 3128 (defines the port for Squid to listen to HTTP client requests)

Cache_mem 10 MB (Squid can use an ideal memory value, usually set to 1/3 of the physical memory)

Cache_swap_low 95

Cache_swap_low 90

Maximum_object_size 4096 KB (objects larger than this value will not be stored)

Cache_dir ufs/var/spool/squid/cache 200 16 256 (specify Squid to store the swap space of the object and its directory structure)

Acl all src 192.168.1.1/24 (defined as 192.168.1.1 network segment)

Http_acceaa allow all (clients in the 192.168.1.1 network segment can use the Squid proxy to access the Internet)

Cache_inclutive_user squid (user and user group used)

Cache_effective_group squid (use the default value for other parameters)

[Root @ squid bin] # chmod 777/var/spool/squid/cache (set the/var/spool/squid/cache directory to a Noboay user with write permission)

[Root @ squid bin] # squid-z (manually create the Squid cache directory/var/spool/squid/cache)

[Root @ squid bin] #/etc/rc. d/init. d/squid start (start Squid, stop Squid with/etc/rc. d/init. d/squid stop)

Test on the client. Take Windows as an example. Run IE, click "Tools", click "Internet Options", click the "connection" tab, and click "LAN Settings". In the "LAN Settings" window, fill in the IP address of the Squid server in "Address": 192.168.1.16, fill in "3128" in "Port", and then exit. In this case, the client should be able to browse the Internet, indicating that Squid is running properly.

Filter configuration

Next, configure the website filtering function. There are two configuration methods.

Method 1

Please renew.

# Rpm-ivh squidguard-1.2.0-3.i386.rpm

(After installation, the data directory Dbhome:/var/squidguard/blacklists; the log directory Logdir:/var/log/squidguard)

Follow the prompts to modify the configuration lines in the/etc/squid. conf file:

Redirect_program/usr/sbin/squidgua-

Rd-c/etc/squid/squidguard. conf

Redirect_child 5

Restart Squid, view/var/log/squidguard. log, and check the last line: 16:13:18 [2237] squidguard ready for requests, which indicates that Squidguard is running properly.

Method 2

Go to squidguard. mesd. k12.or. us/squidguard.tar.gzto download squidguard.tar.gz of tardy and put it in the root directory.

# Cd/(enter the root directory)

# Tar vzxf squidguard.tar.gz

(Decompress the file to/usr/local/squidguard. The data directory is Dbhome:/usr/local/squidguard/db. The log directory is Logdir:/usr/local/squidguard/log)

Modify the/etc/squid/squidguard. conf configuration file:

Redirect_program:/usr/local/bin/squidguard-c/etc/squid/squidguard. conf

Restart Squid and check/usr/local/squid guard/log/squidguard. log to ensure that SquidGuard is running properly.

Try to browse some websites to filter. If the website can be redirected to a specified webpage, it indicates that the filtering function has taken effect.

Data can be increased or decreased when SquidGuard of the TAR version is used. Go to the Data Directory: Porn folder under/usr/local/squidguard/db and create a new Domains. diff file. The content format is (plus sign "+" indicates addition, minus sign "-" indicates removal ):

+ Newsite1 (adds newsite1 to the filter list and cannot be accessed)

+ Newsite2 (adds newsite2 to the filter list and cannot be accessed)

-Site3 (remove site3 from the Filter list for normal access)

-Site4 (remove site4 from the Filter list for normal access)

Then run: #/usr/local/bin/squidguard-c/etc/squid/squidguard. conf-u

View the SquidGuard. log file, if any:

Db update done

Squidguard stopped (102233.823)

Indicates that the data is updated successfully! Restart Squid.

Advantages of this method

The advantage of this method is that it is easy to configure and has low hardware requirements. Generally, 486 and 586 of the retired servers are competent, and the proxy server can work for a long time. All the software is free of charge, and the filter list is updated quickly. You only need to download the latest version of the filter list database at www.squidGuard.org to replace the old one. You can also manually add or remove the Filter list.

Squid can also set the time period for accessing the Internet. It can regularly check logs to detect students' bad tendencies on the Internet. (Source: CCID-China Computer Education News)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.