Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

16.2 Configure the Squid service program


May 24, 2021 That's what Linux should learn



Although the configuration steps for the Squid service program are simple, you still need to account for the equipment required for your experiment and the appropriate settings. F irst you need to prepare two virtual machines, one for the Squid server and the other for the Squid client, which is available on both Windows and Linux systems (windows 7 operating system is used in this lab). In order to be able to communicate with each other, you need to set both virtual machines to Hostonly only, then power off one of the virtual machines and power on after adding a new network card, as shown in Figure 16-3.

16.2 Configure the Squid service program

Figure 16-3 adds a new network card to one of the virtual machines

It is important to note that this newly added network card device must be selected as a bridge mode, otherwise neither virtual machine can access the external network. Configure the IP addresses of these two virtual machines according to Table 16-1.

Table 16-1 Squid server and client operating system and IP address information

Host Name Operating System IP Address Squid Server RHEL 7 External Network Card: Bridge DHCP Mode Intranet Card: 192.168.10 Squid Client Windows 7 192.168.10.20 So we have a virtual machine that can access both the intranet and the external network. In a moment, the Squid service program needs to be deployed on this virtual machine, and then another virtual machine (i.e., the Squid client) that would otherwise have access to the intranet will be able to access the Internet through the Squid server, so that the Squid client can also access external websites.

In addition, we need to check that the Squid server has successfully accessed the external network. You can ping an extranet domain name for testing (manually press ctrl-c to stop).

[root@linuxprobe ~]# ping www.linuxprobe.com PING www.linuxprobe.com (162.159.211.33) 56(84) bytes of data. 6 4 bytes from 162.159.211.33: icmp_seq=1 ttl=45 time=166 ms 64 bytes from 162.159.211.33: icmp_seq=2 ttl=45 time=168 ms 64 bytes from 162.159.211.33: icmp_seq=3 ttl=45 time=167 ms 64 bytes from 162.159.211.33: icmp_seq=4 ttl=45 time=166 ms ^C --- www.linuxprobe.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3006ms rtt min/avg/max/mdev = 1 66.361/167.039/168.109/0.836 ms When the Yum software repository is configured and the device image is mounted, the Squid service program can be installed. G iven that most of the service programs in this book are installed through the Yum software repository, readers should be familiar with this, so we won't go into it here. Of course, you don't have to worry about relying too much on yum repositories to manage software packages, and Chapter 20 explains how to install service programs through source packages.

[root@linuxprobe ~]# yum install squid Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. Y ou can use subscription-manager to register. r hel | 4 .1 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package squid.x86_64 7:3.3.8-11.el7 will be installed --> Processing Dependency: perl(DBI) for package: 7:squid-3.3.8-11.el7.x86_64 --> Processing Dependency: perl(Data::Dumper) for package: 7:squid-3.3.8-11.el7.x86_64 --> Processing Dependency: perl(Digest::MD5) for package: 7: s quid-3.3.8-11.el7.x86_64 --> Processing Dependency: libecap.so.2()(64bit) for package: 7:squid-3.3.8-11.el7.x86_64 --> Running transaction check .................. O mit some of the output information... I nstalled: squid.x86_64 7:3.3.8-11.el7 Dependency Installed: libecap.x86_64 0:0.2.0-8.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-Digest.noarch 0:1.17-245.el7 perl-Digest-MD5.x86_64 0:2.52-3.el7 perl-IO-Compress.noarch 0:2.061-2. e l7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Complete! S imilar to previously configured service programs, the profile of the Squid service program is also stored in the next directory in the /etc directory named after the service. Table 16-2 lists some commonly used Squid service program configuration parameters that you can explore in advance.

Table 16-2 Common Squid service program configuration parameters and effects

Parameter Action http_port 3128 Listen port number cache_mem 64M memory buffer size cache_dir ufs /var/spool/squid 2000 16 256 hard disk buffer size cache_effective_user squid settings cache valid user cache_effective_group squid setting cache valid users Group dns_nameservers IP addresses are generally not set, but instead use the server's default DNS address cache_access_log/var/log/squid/access.log to access the save path of log files cache_log/var/log/squid/cache.log cache the save path of log files visible_hostname linuxprobe.com Set the name of the Squid server