CentOS上部署PPTP和L2TP over IPSec&IPv6 OpenVPN&IPv6环境Squid简要笔记
CentOS上部署PPTP和L2TP over IPSec简要笔记
PPTP部署
安装 PPTP 需要 MPPE 和较高版本的 ppp ( > 2.4.3 ) 支持,不过 CentOS 5.0/RHEL 5 的 2.6.18 内核已经集成了 MPPE 和高版本的 ppp 。因此可以跳过安装配置 MPPE 和 ppp 的过程直接安装 PPTP。
如果需要检查 MPPE 是否存在可以使用以下命令:
shell> modprobe ppp-compress-18 && echo ‘MPPE found !’
1.安装 pptpd
|
1
2
3
4
|
#确保安装了ppp 和 iptablesyum install -y ppp iptableswget http://acelnmp.googlecode.com/files/pptpd-1.3.4-1.rhel5.1.i386.rpmrpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm |
Notice:
- 官网http://poptop.sourceforge.net/已经删掉了1.3.4版的pptpd的RPM,所以只好在这个地方下载
- 判断CentOS系统是32位还是64位?
getconf LONG_BIT
2.配置文件编写
①.配置文件/etc/ppp/options.pptpd
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
mv /etc/ppp/options.pptpd /etc/ppp/options.pptpd.bakcat >>/etc/ppp/options.pptpd<<EOFname pptpdrefuse-paprefuse-chaprefuse-mschaprequire-mschap-v2require-mppe-128proxyarplocknobsdcompnovjnovjccompnologfdidle 2592000ms-dns 8.8.8.8ms-dns 8.8.4.4EOF |
name pptpd : pptpd server 的名称。
refuse-pap : 拒绝 pap 身份验证模式。
refuse-chap : 拒绝 chap 身份验证模式。
refuse-mschap : 拒绝 mschap 身份验证模式。
require-mschap-v2 : 在端点进行连接握手时需要使用微软的 mschap-v2 进行自身验证。
require-mppe-128 : MPPE 模块使用 128 位加密。
ms-dns 8.8.8.8
ms-dns 8.8.4.4 : ppp 为 Windows 客户端提供 DNS 服务器 IP 地址,第一个 ms-dns 为 DNS Master,第二个为 DNS Slave。
proxyarp : 建立 ARP 代理键值。
debug : 开启调试模式,相关信息同样记录在 /var/logs/message 中。
lock : 锁定客户端 PTY 设备文件。
nobsdcomp : 禁用 BSD 压缩模式。
novj
novjccomp : 禁用 Van Jacobson 压缩模式。
nologfd : 禁止将错误信息记录到标准错误输出设备(stderr)。
②.配置文件/etc/ppp/chap-secrets
|
1
2
|
mv /etc/ppp/chap-secrets /etc/ppp/chap-secrets.bakvi /etc/ppp/chap-secrets |
输入以下内容
|
1
2
3
|
# Secrets for authentication using CHAP# client server secret IP addressesmyusername pptpd mypassword * |
③.配置文件/etc/pptpd.conf
|
1
2
3
4
5
6
7
8
|
mv /etc/pptpd.conf /etc/pptpd.conf.bakcat >>/etc/pptpd.conf<<EOF#pptpd.confoption /etc/ppp/options.pptpdlogwtmplocalip 10.82.18.1remoteip 10.82.18.2-254EOF |
注:为拨入VPN的用户动态分配10.82.18.2~10.82.18.254之间的IP
④.配置文件/etc/sysctl.conf(修改内核转发参数)
如上一篇博文所述,可以sysctl -w net.ipv4.ip_forward=1,也可以
|
1
2
|
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.confsysctl -p |
直接替换/etc/sysctl.conf的内容。这样写的好处在于不必在启动脚本/etc/rc.local中添加sysctl -w net.ipv4.ip_forward=1,一劳永逸。
IPSec+L2TP部署
这部分部署方法已经有现成的一键脚本,怕麻烦的用户可以直接拿去跑。但是本着不求甚解的原则还是一步步列出。
L2TP (Layer 2 Tunneling Protocol) 是VPN隧道协议的一种,它使用UDP的1701端口进行通信。L2TP本身并没有任何加密,但是我们可以使用IPSec对L2TP包进行加密。更多关于L2TP的理论知识可以访问这个Wiki
因为联通和移动陆续封掉了 PPTP 数据包,所以L2TP是移动设备VPN几乎唯一选择(OpenVPN配置稍显麻烦)。
在Linux环境下,有很多方法配置L2TP;一个选项是采用openl2tpd,但是他对老版本的ppp隧道支持不好。更重要的是在CentOS环境下,它要求内核需要patch,我想没多少人希望没事给内核patch吧。
基于这个原因,本文选择了xl2tpd & rp-l2tpd,xl2tpd 是由 Xelerance Corporation 维护的l2tpd应用。但是xl2tpd 没有l2tp-control,需要从rp-l2tp这个里面提取。
1.安装OpenSwan
经典的2.6.24这个版本和最新的2.6.32都可以。
|
1
2
3
4
5
6
|
#安装依赖yum install make gcc gmp-devel bison flexwget http://www.openswan.org/download/openswan-2.6.32.tar.gztar zxvf openswan-2.6.32.tar.gzcd openswan-2.6.32make programs install |
①.修改配置文件/etc/ipsec.conf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
mv /etc/ipsec.conf /etc/ipsec.conf.bakcat >>/etc/ipsec.conf<<EOF#ipsec.confversion 2.0config setup nat_traversal=yes virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12 oe=off protostack=netkeyconn L2TP-PSK-NAT rightsubnet=vhost:%priv also=L2TP-PSK-noNATconn L2TP-PSK-noNAT authby=secret pfs=no auto=add keyingtries=3 rekey=no ikelifetime=8h keylife=1h type=transport left=YOUR.SERVER.IP.ADDRESS leftprotoport=17/1701 right=%any rightprotoport=17/%anyEOF |
②.设置 PSK
|
1
2
3
4
|
rm -r /etc/ipsec.secretscat >>/etc/ipsec.secrets<<EOFYOUR.SERVER.IP.ADDRESS %any: PSK "YourSharedSecret"EOF |
③.修改包转发设置
|
1
2
3
4
5
6
7
8
|
for each in /proc/sys/net/ipv4/conf/*doecho 0 > $each/accept_redirectsecho 0 > $each/send_redirectsdone#若PPTP部分设置过,则下面不必在设置sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.confsysctl -p |
重新启动 ipsec,并测试运行效果
|
1
2
|
service ipsec restartipsec verify |
若无FAIL即为正常。
这个时候 ipsec 部分完成了,可以测试一下,新建一个 ipsec+l2tp 的连接,填好服务器地址和 SharedKey,点连接。在服务端
|
1
2
3
|
tail -f /var/log/secure#若出现以下内容,这代表IPSec一切正常#pppd[3624]: IPSec connection established |
2.安装xl2tpd和rp-l2tp
①.下载编译安装
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#安装依赖yum install libpcap-devel ppp#rp-l2tpwget http://downloads.sourceforge.net/project/rp-l2tp/rp-l2tp/0.4/rp-l2tp-0.4.tar.gztar zxvf rp-l2tp-0.4.tar.gzcd rp-l2tp-0.4./configuremakecp handlers/l2tp-control /usr/local/sbin/mkdir /var/run/xl2tpd/ln -s /usr/local/sbin/l2tp-control /var/run/xl2tpd/l2tp-control#xl2tpdcd..wget http://ywko.googlecode.com/files/xl2tpd-1.2.4.tar.gztar zxvf xl2tpd-1.2.4.tar.gzcd xl2tpd-1.2.4make install |
官网的xl2tpd已经404,所以…
②.写配置文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
mkdir /etc/xl2tpdrm -f /etc/xl2tpd/xl2tpd.confcat >>/etc/xl2tpd/xl2tpd.conf<<EOF#/etc/xl2tpd/xl2tpd.conf[global]ipsec saref = yes[lns default]ip range = 10.82.88.2-10.82.88.254local ip = 10.82.88.1refuse chap = yesrefuse pap = yesrequire authentication = yesppp debug = yespppoptfile = /etc/ppp/options.xl2tpdlength bit = yesEOFrm -f /etc/ppp/options.xl2tpdcat >>/etc/ppp/options.xl2tpd<<EOF#/etc/ppp/options.xl2tpdrequire-mschap-v2ms-dns 8.8.8.8ms-dns 8.8.4.4asyncmap 0authcrtsctslockhide-passwordmodemdebugname l2tpdproxyarplcp-echo-interval 30lcp-echo-failure 4EOF |
③.设置密码/etc/ppp/chap-secrets
输入以下内容
|
1
2
3
|
# Secrets for authentication using CHAP# client server secret IP addressesmyusername l2tpd mypassword * |
服务启动
1.配置防火墙iptables
|
1
2
3
4
5
6
|
service iptables start#可以考虑#iptables -t nat -A POSTROUTING -o eth0 -s 10.82.18.0/24 -j MASQUERADE#iptables -t nat -A POSTROUTING -o eth0 -s 10.82.88.0/24 -j MASQUERADE#考虑到之后还要配置L2TP,直接一下倒显得更加简便iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
OpenVZ用户将eth0换成venet0即可。
2.启动
|
1
2
3
4
|
service pptpd startipsec verifyservice ipsec restartxl2tpd |
3.配置自启动脚本,添加以下内容到/etc/rc.local
|
1
2
3
4
5
6
7
8
|
iptables --table nat --append POSTROUTING --jump MASQUERADEfor each in /proc/sys/net/ipv4/conf/*doecho 0 > $each/accept_redirectsecho 0 > $each/send_redirectsdone/etc/init.d/ipsec restart/usr/local/sbin/xl2tpd |
参考资料:
=================================================================
部署IPv6 OpenVPN简要笔记
OpenVPN是一个用于创建VPN加 密通道的软件包,最早由James Yonan编写。大量使用了OpenSSL加密库中的SSLv3/TLSv1协议函数库。目前OpenVPN能在Solaris、Linux、 OpenBSD、FreeBSD、NetBSD、Mac OS X与Windows 2000/XP/Vista上运行,並包含了许多安全性的功能。
服务端
1.安装基础编译工具和OpenSSL
|
1
2
|
CentOS: yum install gcc gcc-c++ kernel-devel openssl-develUbuntu: apt-get install build-essential libssl-dev |
2. 下载LZO和OpenVPN以及IPv6 Patch并编译安装
|
1
2
3
4
5
6
7
8
9
|
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gzwget http://openvpn.net/release/openvpn-2.1.1.tar.gzwget https://github.com/downloads/jjo/openvpn-ipv6/openvpn-2.1.1-ipv6-0.4.11.patch.gz –no-check-certificategunzip -d openvpn-2.1.1-ipv6-0.4.11.patch.gztar zxvf *.tar.gzpatch –p0 < openvpn-2.1.1-ipv6-0.4.11.patchcd lzo-2.04 && ./configure && make && make installcd ../openvpn-2.1.1 && ./configure && make && make installcd .. && cp -r ./openvpn-2.1.1/easy-rsa/ -r /etc/openvpn #拷贝配置文件到/etc/openvpn |
Tips:
如果patch文件这样生成
diff –uN from-file to-file > to-file.patch则
patch –p0 < to-file.patch如果patch文件这样生成
diff –uNr from-docu to-docu >to-docu.patch则
patch –p1 < to-docu.patch
3.生成证书
初始化PKI
|
1
2
3
4
5
6
7
8
9
10
11
|
cd /etc/openvpn/2.0/export D=`pwd`export KEY_CONFIG=$D/openssl.cnfexport KEY_DIR=$D/keysexport KEY_SIZE=1024export KEY_COUNTRY=USexport KEY_PROVINCE=CAexport KEY_CITY=SanFranciscoexport KEY_ORG="logicmd" #引号要用英文半角符号export KEY_EMAIL="i[at]logicmd.net" #引号要用英文半角符号. vars |
4.创建证书颁发机构(CA)
|
1
2
|
./clean-all #这行命令是清空Keys文件夹下的所有文件./build-ca |
接下来的信息你可以自己填写
5. 建立server key
|
1
|
./build-key-server server |
接下来的信息你可以自己填写
6. 生成client key
|
1
|
./build-key client1 # client1 可以自定义 这个是客户的名字 |
接下来的信息你可以自己填写
7.以此类推建立其他客户端 key
当然你也可以不用,也可以在使用中在添加,不过比较麻烦,文章后会有教程
|
1
2
|
./build-key client2./build-key client3 |
注意在进入 Common Name (eg, your name or your server’s hostname) []: 的输入时, 每个证书输入的名字必须不同.
8. 生成Diffie Hellman参数 (这个很重要)
|
1
|
./build-dh |
(如果这里发生错误,请尝试:openssl dhparam -out ./keys/dh1024.pem 1024)
9. 将 keys 下的client.key/crt和ca.crt打包下载到本地(可以通过winscp,http,ftp等等……)
|
1
2
|
#排除掉ca.key和server.keyfind ./ -name "*.crt" -or -name "*.key" -not -name "server.key" -not -name "ca.key" | xargs tar czvf yourkeys.tar.gz |
10.创建服务端配置文件
|
1
2
|
mkdir /etc/openvpn/2.0/confcp /root/openvpn-2.1.1/sample-config-files/server.conf /etc/openvpn/2.0/conf/server.conf |
11.用你最喜欢的编辑器编辑配置文件
(但是不建议记事本/notepad.exe),这里直接放出ipv4和ipv6的OpenVPN的配置文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
local YOUR.SERVER.IPV4.ADDRESSport 8888proto udpdev tunca /etc/openvpn/2.0/keys/ca.crtcert /etc/openvpn/2.0/keys/server.crtkey /etc/openvpn/2.0/keys/server.key # This file should be kept secretdh /etc/openvpn/2.0/keys/dh1024.pemserver 10.8.0.0 255.255.255.0ifconfig-pool-persist /var/log/openvpn/ipp-udp.txtpush "redirect-gateway def1 bypass-dhcp"push "dhcp-option DNS 10.8.0.1"push "dhcp-option DNS 8.8.8.8"push "dhcp-option DNS 8.8.4.4"keepalive 10 120cipher AES-128-CBC # AEScomp-lzo;max-clients 100user nobodygroup nobodypersist-keypersist-tunstatus openvpn-status-udp.loglog /var/log/openvpn/openvpn-udp.log;log-append openvpn.logverb 3 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
local YOUR.SERVER.IPV6.ADDRESSport 9999proto udp6dev tunca /etc/openvpn/2.0/keys/ca.crtcert /etc/openvpn/2.0/keys/server.crtkey /etc/openvpn/2.0/keys/server.key # This file should be kept secretdh /etc/openvpn/2.0/keys/dh1024.pemserver 10.8.1.0 255.255.255.0ifconfig-pool-persist /var/log/ipp-udp6.txtpush "redirect-gateway def1 bypass-dhcp"push "dhcp-option DNS 10.8.1.1"push "dhcp-option DNS 8.8.8.8"push "dhcp-option DNS 8.8.4.4"keepalive 10 120cipher AES-128-CBC # AEScomp-lzo;max-clients 100user nobodygroup nobodypersist-keypersist-tunstatus /var/log/openvpn-status-udp6.loglog /var/log/openvpn/openvpn-udp6.log;log-append openvpn.logverb 3 |
12.OpenVPN 访问外网的设置(如果不设置,你连上后只能在你和VPS之间建立VPN)
如果你跟偶一样很多类型VPN,很多NAT的话直接
|
1
|
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
如果你想精细控制不同NAT地址转发情况的话,可以分别设置
|
1
2
3
4
|
#OpenVPN IPv4iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE#OpenVPN IPv6iptables -t nat -A POSTROUTING -s 10.8.1.0/24 -o eth0 -j MASQUERADE |
(如果你运行上面的出现 iptables: Unknown error 4294967295 这样的错误,可以尝试下面的)
/sbin/iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -j SNAT –to-source [你的IP地址]
对于OpenVZ的VPS讲eth0换成venet0即可
继续输入
|
1
2
|
service iptables saveservice iptables restart |
修改包转发设置
|
1
|
sysctl -w net.ipv4.ip_forward=1 |
13. 设置 OpenVPN 服务器 reboot后自动启动 openvpn
|
1
2
3
4
5
6
|
vim /etc/rc.local#添加以下内容/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server-udp.conf &/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server-udp6.conf &sysctl -w net.ipv4.ip_forward=1iptables --table nat --append POSTROUTING --jump MASQUERADE |
虽说是前面save了iptables到系统文件,但是根据我的经验,VPS down掉重启后,还是需要重新设置iptables。
14.最后启动 OpenVPN
|
1
2
3
4
5
6
|
/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server-udp.conf &/usr/local/sbin/openvpn --config /etc/openvpn/2.0/conf/server-udp6.conf &#如要看到日志可以如此观看tail -f /var/log/openvpn/openvpn-udp.log#或者tail -f /var/log/openvpn/openvpn-udp6.log |
15.添加一个小脚本,用于继续添加客户端的KEY
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#!/bin/bashcd /etc/openvpn/2.0/export D=`pwd`export KEY_CONFIG=$D/openssl.cnfexport KEY_DIR=$D/keysexport KEY_SIZE=1024export KEY_ORG="logicmd"export KEY_EMAIL="i[at]logicmd.net"export KEY_COUNTRY=USexport KEY_PROVINCE=CAexport KEY_CITY=SanFrancisco./vars./build-key $1 |
客户端
1.分发配置文件给用户
将配置文件vpn.ovpn,证书 ca.crt client.crt client.key分发给用户。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
clientdev tunproto udpremote YOUR.SERVERS.IPV4.DOMAINNAME 8888resolv-retry infinitenobind#个人感觉客户端不必,降权后不利于路由表管理;user nobody;group nobodypersist-keypersist-tunca ca.crtcert logicmd.crtkey logicmd.keyns-cert-type servercipher AES-128-CBC # AEScomp-lzoverb 2mute 20script-security 2# Here comes the route table.max-routes 1500 |
接下来按照 给VPN添加路由表 添加路由表即可。
2.客户端的安装
具体详见VPN配置手册
- Windows用户需要下载官网安装包
对于需要使用VPN Over IPv6的童鞋下载IPv6 Patched的openvpn.exe 替换掉X:\Program Files\OpenVPN\bin相应文件。 - Linux用户则应该按照本文开始服务器端的安装方法同样在客户端安装OpenVPN。Linux中OpenVPN的配置文件证书位置似乎不支持相对路径。
FAQ
1.Windows路由表速度过慢
删掉以下
route-method exe route-delay 2
2.满屏幕的路由信息看着烦.opvn改成
verb 2 mute 20
即可。
==================================================================
CentOS部署IPv6环境Squid简要笔记
Squid Cache(简称为Squid)是一个流行的自由软件(GNU通用公共许可证)的代理服务器和Web缓存服务器。Squid有 广泛的用途,从作为网页服务器的前置cache服务器缓存相关请求来提高Web服务器的速度,到为一组人共享网络资源而缓存万维网,域名系统和其他网络搜 索,到通过过滤流量帮助网络安全,到局域网通过代理上网。Squid的功能也相当完善,3.1之后的版本已经默认开启并支持了ipv6。
本文是如何在CentOS环境下部署Squid over IPv6
下载安装
去http://people.redhat.com/jskala/squid/下载最新版本的Squid rpm包。
|
1
2
3
4
5
6
7
|
#安装依赖yum install perl-DBI# 注意自己的构架是否为i386http://people.redhat.com/jskala/squid/squid-3.1.8-1.el5/i386/squid-3.1.8-1.el5.i386.rpmrpm -ivh squid-3.1.8-1.el5.i386.rpm |
配置/etc/squid/squid.conf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
## Recommended minimum configuration:#acl manager proto cache_objectacl localhost src 127.0.0.1/32 ::1acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1# Example rule allowing access from your local networks.# Adapt to list your (internal) IP networks from where browsing# should be allowedacl localnet src 10.0.0.0/8 # RFC1918 possible internal networkacl localnet src 172.16.0.0/12 # RFC1918 possible internal networkacl localnet src 192.168.0.0/16 # RFC1918 possible internal networkacl localnet src fc00::/7 # RFC 4193 local private network rangeacl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines# 使用预定义的ipv6定义ipv6地址源acl in_ipv6 src ipv6# 定义不能访问的网站acl ban dstdomain "/etc/squid/bansite"acl SSL_ports port 443acl Safe_ports port 80 # httpacl Safe_ports port 21 # ftpacl Safe_ports port 443 # httpsacl Safe_ports port 70 # gopheracl Safe_ports port 210 # waisacl Safe_ports port 1025-65535 # unregistered portsacl Safe_ports port 280 # http-mgmtacl Safe_ports port 488 # gss-httpacl Safe_ports port 591 # filemakeracl Safe_ports port 777 # multiling httpacl CONNECT method CONNECT## Recommended minimum Access Permission configuration:## Only allow cachemgr access from localhosthttp_access allow manager localhosthttp_access deny manager# Deny requests to certain unsafe portshttp_access deny !Safe_ports# Deny CONNECT to other than secure SSL portshttp_access deny CONNECT !SSL_ports# We strongly recommend the following be uncommented to protect innocent# web applications running on the proxy server who think the only# one who can access services on "localhost" is a local userhttp_access deny to_localhost## INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS## Example rule allowing access from your local networks.# Adapt localnet in the ACL section to list your (internal) IP networks# from where browsing should be allowed# 不允许访问前面预定义的网址http_access deny banhttp_access allow localnethttp_access allow localhost# 只允许ipv6的地址来源的计算机使用本代理http_access allow in_ipv6# And finally deny all other access to this proxyhttp_access deny all# Squid normally listens to port 3128http_port 3128# 是透明代理 or 匿名代理(X-Forwarded-For字段)forwarded_for on# 最大下载文件大小maximum_object_size 100 MB# We recommend you to use at least the following line.hierarchy_stoplist cgi-bin ?# Uncomment and adjust the following to add a disk cache directory.cache_dir ufs /var/spool/squid 100 16 256cache_mem 16 MB #RAM比较小嘛~# Leave coredumps in the first cache dircoredump_dir /var/spool/squid# Add any of your own refresh_pattern entries above these.refresh_pattern ^ftp: 1440 20% 10080refresh_pattern ^gopher: 1440 0% 1440refresh_pattern -i (/cgi-bin/|\?) 0 0% 0refresh_pattern . 0 20% 4320 |
|
1
2
3
|
#/etc/squid/bansite.xxoo.com.xxx.net |
启动服务
|
1
2
|
chkconfig --levels 2345 squid onservice squid restart |
更多的配置选项可以参考鸟哥私房菜,非常易懂的一份中文配置Squild资料。
当然文章有点老了,很多配置选项已经deprecated了,必要时还需要到Squid官网config文档去查询3.1版中哪些选项还能用。
Squid还可以完成限制下载特定后缀的文件啦,工作时间限制访问网站啦,设置VIP用户白名单啦,限制p2p啦,本文只是着眼于IPv6网络内容,更多的需求大家自行搜索。
FAQ
1.Squid 编译时候带IPv6,但却不处理IPv6来的请求
- Squid可能配配置的只处理IPv4请求
squid.conf 的配置 (http_port, icp_port, snmp_port, https_port 或者其他 ) 可以是以下形式 port, hostname:port, or ip:port,如果hostname只有A记录或者IP是IPv4当然只会处理v4的请求。
- Squid可能被配置了太过严格的 ACL.
在处理传统的ACL配置时最好考虑到IPv6地址,比如默认的localhost 的ACL随着加入对IPv6的考虑演进成
acl localhost src 127.0.0.1 ::1
2.经常出现的错误
- 定义acl all src ::/0 0.0.0.0/0
all在Squid 3中已经预定义过了。
- 定义acl IPv4 with ::ffff:a.b.c.d
Squid本身可以理解IPv4地址,而且ipv4在Squid中也预定义过了。
- 定义acl IPv6 as 2000::/3
其实IPv6远不止这些地址,而且ipv4在Squid中也预定义过了。
当然要是想限制Squid为某些学校访问倒是可以参考下表
参考资料:
Squid Web Proxy Wiki
原文:
http://logicmd.net/2010/12/setup-pptp-and-l2tp-over-ipsec-on-centos/
