yum -y install dhcp
cp /163.17.209.1/etc/dhcp/dhcpd.conf /etc/dhcp/.
vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
ignore client-updates;
option nis-domain "wcjs.tc.edu.tw";
option routers 163.17.209.254;
option domain-name "w252.wcjs.tc.edu.tw";
option domain-name-servers 163.17.209.1, 168.95.1.1, 8.8.8.8;
option time-offset -18000; # Eastern Standard Time
default-lease-time 28800;
max-lease-time 28800;
authoritative;
subnet 163.17.209.0 netmask 255.255.255.0 {
range dynamic-bootp 163.17.209.75 163.17.209.200;
host Epson6500 {
hardware ethernet 00:00:48:cc:9b:e5;
fixed-address 163.17.209.81;
}
}
systemctl start dhcpd
systemctl status dhcpd
systemctl enable dhcpd
firewall-cmd --add-service=dhcp --permanent
firewall-cmd --reload
2016年8月11日 星期四
CentOS 7.2 Proxy Server (Squid) 安裝及基本設定(一)
yum -y install squid
cp /163.17.209.1/etc/squid/squid.conf /etc/squid/.
vim /etc/squid/squid.conf
# add follows to the end
request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
# do not display IP address
forwarded_for off
chown -R squid:squid /cache1
systemctl start squid
systemctl status squid
systemctl enable squid
firewall-cmd --add-service=squid --permanent
firewall-cmd --reload
cp /163.17.209.1/etc/squid/squid.conf /etc/squid/.
vim /etc/squid/squid.conf
# add follows to the end
request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
# do not display IP address
forwarded_for off
chown -R squid:squid /cache1
systemctl start squid
systemctl status squid
systemctl enable squid
firewall-cmd --add-service=squid --permanent
firewall-cmd --reload
CentOS 6.8 Proxy Server (Squid) 安裝及基本設定(一)
網頁代理伺服器 (Squid)
利用yum 安裝即可
指令:
yum install squid -y
/bin/cp /163.17.209.6/etc/squid/squid.conf /etc/squid/. -f chown -R squid:squid /cache1
service squid restart
預設設定檔路徑 /etc/squid/squid.conf
預設使用 port : 3128 (可自行修改)
啟動服務指令 : service squid start
檢查 port 3128 有沒有正常開啟
指令 : netstat –antp
一些常用基本設定
修改/etc/squid/squid.conf
1. 設定開啟快取目錄
快取目錄就是squid 的硬碟,當USER要求網頁資料時,squid 就快將資料存放置快取目錄如果使用者連線到網站時,squid 會先檢查快取目錄是否有相同的資料,如果有相同資料就不會去網路下載一份, 而是直接將快取目錄中的資料給使用者,如果又有另外一個USER要求相同的網頁資料,但是squid如果發現網頁內容有變動也會自動去下載一份新版資料放置快取區
cache_dir ufs /var/spool/squid 100 16 256 (預設不啟用,移除#將他起用)
如過要將cache 修改為2G 則
cache_dir ufs /var/spool/squid 2000 16 256
2.設定自動清除快取資料
- cache_swap_low 90
- cache_swap_high 95
以上設定表示當磁碟使用量達 95% 時,比較舊的快取資料將會被刪除,當刪除到剩下磁碟使用量達 90% 時,就停止持續刪除的動作
3.清除快取資料
- 須先停止squid 服務 —-> service squid stop
- 切換到快取目錄 cd /var/spool/squid
- 刪除 sqap.state —-> rm –rf /var/spool/squid/swap.state
- 刪除後重新啟動服務即可 —-> service squid start
Squid ACL 設定
限制單一IP(192.168.1.150)無法連線
acl test src 192.168.1.150/32
http_access deny test
說明 :
test 是自訂名稱,上下兩個名稱要一致才可以
限制某一區段無法連線(192.168.1.150-192.168.1.200)無法連線
acl test src 192.168.1.150-192.168.0.200/32
http_access deny test
限制某個網域下的網站無法存取
acl domain dstdomain .pchome.com.tw
http_access deny domain
2015/02/25 15:53:42| WARNING: Could not determine this machines public hostname. Please configure one or set 'visible_hostname'.
................ [ 確定 ]
正在啟動 squid:. [ 確定 ]
[root@w231 ~]#
Trying other mirror.
http://ftp.stu.edu.tw/Linux/CentOS/6/updates/x86_64/Packages/squid-3.1.10-22.el6_5.x86_64.rpm: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
ftp://ftp.free.fr/mirrors/ftp.centos.org/6/updates/x86_64/Packages/squid-3.1.10-22.el6_5.x86_64.rpm: [Errno 14] PYCURL ERROR 19 - "Given file does not exist"
Trying other mirror.
ftp://mirror.anl.gov/pub/centos/6/updates/x86_64/Packages/squid-3.1.10-22.el6_5.x86_64.rpm: [Errno 12] Timeout on ftp://mirror.anl.gov/pub/centos/6/updates/x86_64/Packages/squid-3.1.10-22.el6_5.x86_64.rpm: (28, 'connect() timed out!')
Trying other mirror.
Error Downloading Packages:
7:squid-3.1.10-22.el6_5.x86_64: failure: Packages/squid-3.1.10-22.el6_5.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
[root@www6 ~]# ^C
[root@www6 ~]#
清除下載資料(/var/cache/yum)
yum clean all
###################
訂閱:
文章 (Atom)