|NO.Z.00017|——————————|^^ 構建 ^^|——|squid快取/代理服務.V2|-------------------------------|4臺server|
阿新 • • 發佈:2022-03-22
[Applications:squid快取/代理服務.V2] [Applications.LBC&HAC$HPC] [叢集|squid快取/代理服務|squid傳統模式|squid透明模式|squid反向代理模式|ACL|HTTP_ACCESS|4臺server]
一、搭建squid傳統模式:實驗拓撲
二、系統硬體規劃
三、實驗專題: 1、配置客戶端### --- 系統硬體規劃 ~~~ HA-server1:10.10.10.11:client:模擬的是客戶端機制 ~~~ HA-server2:10.10.10.12:SQUID:模擬的是SQUID的第一塊網絡卡 主要功能是與客戶端進行通訊 ~~~ HA-server2:20.20.20.12:SQUID:模擬的是SQUID的公網地址,用來去訪問公網 ~~~ HA-server3:20.20.20.13:Apache:使用Apache模擬一個公網伺服器
2、配置公網伺服器### --- 配置客戶端 ### --- 10.10.10.11配置 ### --- 新增一個閘道器指向squid伺服器 [root@server11 ~]# echo "GATEWAY=10.10.10.12" >> /etc/sysconfig/network-scripts/ifcfg-eth0 [root@server11 ~]# service network restart [root@server11 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.10.10.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 0.0.0.0 10.10.10.12 0.0.0.0 UG 0 0 0 eth0 //去任何地方交給10.10.10.12 預設路由
### --- 配置公網伺服器
### --- 10.10.10.13下配置
### --- 修改IP地址
[root@server13 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=20.20.20.13
NETMASK=255.255.255.0
[root@server13 ~]# service network restart
3、配置閘道器伺服器或者說是squid伺服器### --- 開啟Apache服務 [root@server13 ~]# service httpd start [root@server13 ~]# echo "this is server 1" >> /var/www/html/index.html [root@server13 ~]# curl localhost this is server 1
### --- 配置閘道器伺服器或者說是squid伺服器
### --- 10.10.10.12下配置
### --- 開啟第二塊網絡卡
[root@server12 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=20.20.20.12
NETMASK=255.255.255.0
[root@server12 ~]# service network restart
### --- 開啟路由轉發,此環境涉及到一個數據包的轉發問題。所以需要開啟路由轉發。
[root@server12 ~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1 //由0改為1
[root@server12 ~]# sysctl -p
### --- 安裝squid服務
[root@server12 ~]# yum install -y squid
[root@server12 ~]# vim /etc/squid/squid.conf // 傳統模式下配置檔案保持不變就可以使其生效
[root@server12 ~]# service squid start
四、驗證:
### --- 10.10.10.11下驗證
### --- 開啟10.10.10.11圖形化介面
[root@server11 ~]# startx // 或者init 5進入圖形化
~~~ 通過虛擬機器內部的Firefox瀏覽器訪問公網IP地址:20.20.20.13 目前是訪問不到的,是需
~~~ 傳統模式下需要在瀏覽器裡指定它的IP及閘道器的:Firefox——>首選項
~~~ ——>設定——>最後一個——>網路——>配置Firefox如何連線至國際網際網路:
~~~ 設定——>手動配置代理:10.10.10.13 3128 勾選:
~~~ 為所有協議使用可代理(S)——> 確定——>END
~~~ 通過Firefox訪問http://20.20.20.13即可獲取資料: this is server 1
### --- 驗證快取:
[root@server13 ~]# service httpd stop // stop HA-server3的httpd服務
~~~ 直接把HA-server1還原初始快照。
~~~ 通過Firefox訪問http://20.20.20.13即可獲取資料: this is server 1 //此時的資料是從squid快取服務中獲取的資料。
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)