<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LinuxByte &#187; 透明代理</title>
	<atom:link href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxbyte.org</link>
	<description>一个Linux Blog</description>
	<lastBuildDate>Thu, 26 Jan 2012 08:13:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>网吧Linux 网关设置记录补充</title>
		<link>http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html</link>
		<comments>http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html#comments</comments>
		<pubDate>Thu, 03 Nov 2011 02:23:43 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[服务器应用]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[nat]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[透明代理]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=766</guid>
		<description><![CDATA[很早之前写过这篇博文网吧Linux 网关设置记录，现在这台服务器终于玩完了，所以又要重新配置一台了。这次系统用的是CentOS 6 所以，有些东西变了，要记录一下。 squid.conf 中原来的 acl all src 0... ]]></description>
			<content:encoded><![CDATA[<p>很早之前写过这篇博文<a href="http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html">网吧Linux 网关设置记录</a>，现在这台服务器终于玩完了，所以又要重新配置一台了。这次系统用的是CentOS 6 所以，有些东西变了，要记录一下。</p>
<p>squid.conf 中原来的 acl all src 0.0.0.0/0，现在不需要定义了，squid 3.0 以后all 字段是默认设置了。<br />
<span id="more-766"></span><br />
sysctl.conf 优化中</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = <span style="color: #000000;">900</span></pre></div></div>

<p>net.ipv4.netfilter.ip_conntrack_tcp_timeout_established 已经改名了，改为net.netfilter.nf_conntrack_tcp_timeout_established 。</p>
<p>其实这一系列网络参数现在都改为net.netfilter.nf 开头了，所以原来的sysctl.conf 优化语句要改一下了。<br />
我的优化语句</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">net.netfilter.nf_conntrack_tcp_timeout_established= <span style="color: #000000;">180</span>
net.netfilter.nf_conntrack_tcp_timeout_fin_wait= <span style="color: #000000;">120</span>
net.netfilter.nf_conntrack_tcp_timeout_close_wait= <span style="color: #000000;">60</span>
net.netfilter.nf_conntrack_tcp_timeout_last_ack= <span style="color: #000000;">30</span>
net.netfilter.nf_conntrack_tcp_timeout_time_wait= <span style="color: #000000;">120</span>
net.ipv4.tcp_tw_reuse = <span style="color: #000000;">1</span>
net.ipv4.tcp_tw_recycle = <span style="color: #000000;">1</span>
net.ipv4.tcp_fin_timeout = <span style="color: #000000;">30</span>
net.ipv4.icmp_echo_ignore_all = <span style="color: #000000;">0</span>
net.ipv4.conf.all.proxy_arp = <span style="color: #000000;">1</span>
net.ipv4.tcp_synack_retries = <span style="color: #000000;">3</span></pre></div></div>

<p>另外加一条</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-s</span> 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> <span style="color: #660033;">-i</span> eth1 <span style="color: #660033;">-p</span> upd <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> REDIRECT <span style="color: #660033;">--to-port</span> <span style="color: #000000;">53</span></pre></div></div>

<p>强制所有内网DNS请求都有网关解析。</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html" title="网吧Linux 网关设置记录">网吧Linux 网关设置记录</a></li><li><a href="http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html" title="Squid 透明代理优化">Squid 透明代理优化</a></li><li><a href="http://www.linuxbyte.org/refreshpattern-xue-xi-fan-li.html" title="refresh_pattern 学习范例">refresh_pattern 学习范例</a></li><li><a href="http://www.linuxbyte.org/guan-yu-squid-de-yi-xie-ji-lu.html" title="关于squid的一些记录">关于squid的一些记录</a></li><li><a href="http://www.linuxbyte.org/squid-xian-zhi-yong-hu-bing-fa-lian-jie-shu-2.html" title="Squid 限制用户并发连接数">Squid 限制用户并发连接数</a></li><li><a href="http://www.linuxbyte.org/%e5%8d%87%e7%ba%a7squid-26-%e5%88%b027-%e7%9a%84%e5%86%a4%e6%9e%89%e8%b7%af.html" title="升级squid 2.6 到2.7 的冤枉路">升级squid 2.6 到2.7 的冤枉路</a></li><li><a href="http://www.linuxbyte.org/squid-unofficial-support-for-rhelcentos.html" title="Squid unofficial support for RHEL/CentOS">Squid unofficial support for RHEL/CentOS</a></li><li><a href="http://www.linuxbyte.org/wang-ba-mei-ip-xian-su-bu-chong-squid-xian-su.html" title="网吧每IP 限速补充（squid 限速）">网吧每IP 限速补充（squid 限速）</a></li><li><a href="http://www.linuxbyte.org/iptables%ef%bc%8dtc-wang-ba-mei-ip-xian-su-jiao-ben.html" title="Iptables＋tc 网吧每IP 限速脚本">Iptables＋tc 网吧每IP 限速脚本</a></li><li><a href="http://www.linuxbyte.org/yong-iptables-er-fei-tc-xian-zhi-liu-liang.html" title="用Iptables 而非tc 限制流量">用Iptables 而非tc 限制流量</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2011<br />
Source: <a href="http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html">网吧Linux 网关设置记录补充</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/iptables" rel="tag">iptables</a>, <a href="http://www.linuxbyte.org/tag/nat" rel="tag">nat</a>, <a href="http://www.linuxbyte.org/tag/squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" rel="tag">透明代理</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/iptables" title="iptables" rel="tag">iptables</a>, <a href="http://www.linuxbyte.org/tag/nat" title="nat" rel="tag">nat</a>, <a href="http://www.linuxbyte.org/tag/squid" title="squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" title="透明代理" rel="tag">透明代理</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squid 透明代理优化</title>
		<link>http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html</link>
		<comments>http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html#comments</comments>
		<pubDate>Wed, 02 Mar 2011 12:14:20 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[服务器应用]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[透明代理]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=626</guid>
		<description><![CDATA[主要记录下用Squid 做正向代理（透明代理）时的优化设置，一切尚在调试中所以下面的优化方式未必都是正确的。 内核调整 /etc/sysctl.conf 下面添加 net.ipv4.netfilter.ip_conntrack_tcp_timeout_established =900... ]]></description>
			<content:encoded><![CDATA[<p>主要记录下用Squid 做正向代理（透明代理）时的优化设置，一切尚在调试中所以下面的优化方式未必都是正确的。</p>
<p><strong>内核调整</strong><br />
/etc/sysctl.conf 下面添加<br />
<span id="more-626"></span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">net.ipv4.netfilter.ip_conntrack_tcp_timeout_established =900
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.conf.all.proxy_arp = 1
net.ipv4.tcp_synack_retries = 3
net.ipv4.ip_conntrack_max = 81920
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000</pre></div></div>

<p>使设置生效</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>sysctl <span style="color: #660033;">-p</span></pre></div></div>

<p><strong>文件系统设置</strong><br />
将squid缓存放入独立的文件系统中，文件系统格式建议用Reiserfs，挂载时使用&#8217;noatime&#8217;参数提高IO性能。</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">LABEL=/squid             /squid               reiserfs    defaults,noatime     0 0</pre></div></div>

<p><strong>squid.conf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">http_port 192.168.0.254:3128 transparent
cache_mgr hew@linuxbyte.org
cache_mem 512 MB
cache_dir ufs /squid/squid 51200 12 256
maximum_object_size_in_memory 128 KB
maximum_object_size 64 MB
&nbsp;
#cache_access_log /var/log/squid/access.log squid
cache_access_log none
cache_log none
cache_store_log none
#logfile_rotate 4
&nbsp;
max_filedesc 6144
pipeline_prefetch on
memory_pools off
memory_pools_limit none
mime_table /etc/squid/mime.conf
&nbsp;
refresh_pattern -i \.css$ 1440 50% 129600 reload-into-ims
refresh_pattern -i \.xml$ 1440 50% 129600 reload-into-ims
refresh_pattern -i \.htm$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.html$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.shtml$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.png$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.jpg$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.jpeg$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.gif$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.bmp$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.js$ 1440 90% 129600 reload-into-ims
&nbsp;
refresh_pattern -i \.mp3$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.wmv$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.rm$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.swf$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.mpeg$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.wma$ 1440 50% 2880 ignore-reload
&nbsp;
refresh_pattern -i \.exe$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.rar$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.zip$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.gz$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.bz2$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.7z$ 1440 50% 2880 ignore-reload
&nbsp;
client_lifetime 1 hours
half_closed_clients off
visible_hostname proxy.linuxbyte.org
&nbsp;
cache_effective_user squid
cache_effective_group squid
&nbsp;
cache_swap_low 75
cache_swap_high 95
&nbsp;
dns_nameservers 192.168.0.254
&nbsp;
acl QUERY urlpath_regex -i cgi-bin \?
cache deny QUERY
&nbsp;
acl all src 0.0.0.0/0
acl localnet src 192.168.0.0/24
http_access allow localnet
http_access deny all</pre></div></div>

<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html" title="网吧Linux 网关设置记录补充">网吧Linux 网关设置记录补充</a></li><li><a href="http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html" title="网吧Linux 网关设置记录">网吧Linux 网关设置记录</a></li><li><a href="http://www.linuxbyte.org/refreshpattern-xue-xi-fan-li.html" title="refresh_pattern 学习范例">refresh_pattern 学习范例</a></li><li><a href="http://www.linuxbyte.org/guan-yu-squid-de-yi-xie-ji-lu.html" title="关于squid的一些记录">关于squid的一些记录</a></li><li><a href="http://www.linuxbyte.org/squid-xian-zhi-yong-hu-bing-fa-lian-jie-shu-2.html" title="Squid 限制用户并发连接数">Squid 限制用户并发连接数</a></li><li><a href="http://www.linuxbyte.org/%e5%8d%87%e7%ba%a7squid-26-%e5%88%b027-%e7%9a%84%e5%86%a4%e6%9e%89%e8%b7%af.html" title="升级squid 2.6 到2.7 的冤枉路">升级squid 2.6 到2.7 的冤枉路</a></li><li><a href="http://www.linuxbyte.org/squid-unofficial-support-for-rhelcentos.html" title="Squid unofficial support for RHEL/CentOS">Squid unofficial support for RHEL/CentOS</a></li><li><a href="http://www.linuxbyte.org/wang-ba-mei-ip-xian-su-bu-chong-squid-xian-su.html" title="网吧每IP 限速补充（squid 限速）">网吧每IP 限速补充（squid 限速）</a></li><li><a href="http://www.linuxbyte.org/qzone-squid-iptables.html" title="新版qzone 无法被squid 缓存">新版qzone 无法被squid 缓存</a></li><li><a href="http://www.linuxbyte.org/squid-havp-clamav.html" title="squid+havp+clamav搭建防毒代理">squid+havp+clamav搭建防毒代理</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2011<br />
Source: <a href="http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html">Squid 透明代理优化</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" rel="tag">透明代理</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/squid" title="squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" title="透明代理" rel="tag">透明代理</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>网吧Linux 网关设置记录</title>
		<link>http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html</link>
		<comments>http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html#comments</comments>
		<pubDate>Tue, 27 May 2008 05:52:04 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[服务器应用]]></category>
		<category><![CDATA[dns cache]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[nat]]></category>
		<category><![CDATA[pdnsd]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[而且]]></category>
		<category><![CDATA[透明代理]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=150</guid>
		<description><![CDATA[这两天忙着网吧搬家的事，昨晚完成了网关的初步设置，用 centos 5.1下 iptables+squid 2.6 做透明代理 pdnsd 做dns cache, 所用软件除pdnsd 外都是系统自带的，eth0 192.168.0.254 内网，eth1 218.108.x.x 外网。... ]]></description>
			<content:encoded><![CDATA[<p>这两天忙着网吧搬家的事，昨晚完成了网关的初步设置，用 centos 5.1下 iptables+squid 2.6 做透明代理 pdnsd 做dns cache, 所用软件除pdnsd 外都是系统自带的，eth0 192.168.0.254 内网，eth1 218.108.x.x 外网。废话少说直接上配置文件。</p>
<p><span id="more-150"></span><br />
iptables：(/etc/sysconfig/iptables)</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;"># Manual customization of this file is not recommended.
# nat
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -s 192.168.0.0/24 -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A POSTROUTING -s 192.168.0.0/24 -o eth1 -j SNAT --to 218.108.x.x
COMMIT
&nbsp;
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT</pre></div></div>

<p>防火墙默认规则是全部 ACCEPT 因为网吧环境里各种网络应用都有如果是全部DROP 然后开放指定端口的话要花很多时间去找，并且万一有什么新的应用还要再分析再开放很费时间，弄不好客人都跑了，所以只能放弃一些安全性了。<br />
/etc/sysctl.conf</p>
<p>在 /etc/sysctl.conf 末尾加入下面语句</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;">net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 900
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.conf.all.proxy_arp = 1
net.ipv4.tcp_synack_retries = 3</pre></div></div>

<p>/etc/squid/squid.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;">http_port 192.168.0.123:3128 transparent
cache_mgr haibo.d@gmail.com
cache_mem 256 MB
cache_dir ufs /data/squid 500 12 256
&nbsp;
cache_access_log none
cache_log none
cache_store_log none
&nbsp;
maximum_object_size 4096 KB
minimum_object_size 1 KB
&nbsp;
client_lifetime 1 hours
half_closed_clients off
visible_hostname proxy.linuxbyte
&nbsp;
cache_effective_user squid
cache_effective_group squid
&nbsp;
cache_swap_low 75
cache_swap_high 95
&nbsp;
dns_nameservers 192.168.0.1
&nbsp;
acl QUERY urlpath_regex -i cgi-bin \?
cache deny QUERY
&nbsp;
acl all src 0.0.0.0/0
acl localnet src 192.168.0.0/24
http_access allow localnet
http_access deny all</pre></div></div>

<p>这个配置文件是从squid 2.5 改过来的，也许不是完全符合squid 2.6 规范。<br />
pdnsd —— dns cache</p>
<p>pdnsd 是一个小型的dns cache 服务器，为网吧这样的环境做dns cache 刚好够用。<br />
从下面地址下载pdnsd 的相应包安装<br />
<a href="http://www.phys.uu.nl/~rombouts/pdnsd/dl.html">http://www.phys.uu.nl/~rombouts/pdnsd/dl.html</a></p>
<p>/etc/pdnsd.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;">// Sample pdnsd configuration file. Must be customized to obtain a working pdnsd setup!
// Read the pdnsd.conf(5) manpage for an explanation of the options.
// Add or remove '#' in front of options you want to disable or enable, respectively.
// Remove '/*' and '*/' to enable complete sections.
&nbsp;
global {
        perm_cache=2048;
        cache_dir=&quot;/var/cache/pdnsd&quot;;
#       pid_file = /var/run/pdnsd.pid;
        run_as=&quot;pdnsd&quot;;
        server_ip = eth0;  # Use eth0 here if you want to allow other
                                # machines on your network to query pdnsd.
        status_ctl = on;
#       paranoid=on;       # This option reduces the chance of cache poisoning
                           # but may make pdnsd less efficient, unfortunately.
        query_method=udp_tcp;
        min_ttl=60m;       # Retain cached entries at least 60 minutes.
        max_ttl=1w;        # One week.
        timeout=5;        # Global timeout option (10 seconds).
        run_ipv4=on;
}
&nbsp;
# The following section is most appropriate if you have a fixed connection to
# the Internet and an ISP which provides good DNS servers.
server {
        label= &quot;myisp&quot;;
        ip = 202.101.172.35,202.101.172.46;  # Put your ISP's DNS-server address(es) here.
        proxy_only=on;     # Do not query any name servers beside your ISP's.
                           # This may be necessary if you are behind some
                           # kind of firewall and cannot receive replies
                           # from outside name servers.
        timeout=4;         # Server timeout; this may be much shorter
                           # that the global timeout option.
        uptest=none;         # Test if the network interface is active.
        interface=eth0;    # The name of the interface to check.
        interval=10m;      # Check every 10 minutes.
        purge_cache=on;   # Keep stale cache entries in case the ISP's
                           # DNS servers go offline.
}
&nbsp;
/*
# The following section is more appropriate for dial-up connections.
# Read about how to use pdnsd-ctl for dynamic configuration in the documentation.
server {
        label= &quot;dialup&quot;;
        file = &quot;/etc/ppp/resolv.conf&quot;;  # Preferably do not use /etc/resolv.conf
        proxy_only=on
        timeout=4;
        uptest=if;
        interface = ppp0;
        interval=10;       # Check if the interface every 10 seconds.
        purge_cache=off;
        preset=off;
}
*/
&nbsp;
/*
# The servers provided by OpenDNS are fast, but they do not reply with
# NXDOMAIN for non-existant domains, instead they supply you with an
# address of one of their search engines. They also lie about the addresses of
# of the search engines of google, microsoft and yahoo.
# If you do not like this behaviour the &quot;reject&quot; option may be useful.
server {
        label = &quot;opendns&quot;;
        ip = 208.67.222.222, 208.67.220.220;
        reject = 208.69.32.0/24,  # You may need to add additional address ranges
                 208.69.34.0/24,  # here if the addresses of their search engines
                 208.67.219.0/24; # change.
        reject_policy = fail;     # If you do not provide any alternative server
                                  # sections, like the following root-server
                                  # example, &quot;negate&quot; may be more appropriate here.
        timeout = 4;
        uptest = ping;            # Test availability using ICMP echo requests.
        ping_timeout = 100;       # ping test will time out after 10 seconds.
        interval = 15m;           # Test every 15 minutes.
        preset = off;
}
*/
&nbsp;
/*
# This section is meant for resolving from root servers.
server {
        label = &quot;root-servers&quot;;
        root_server = on;
        randomize_servers = on; # Give every root server an equal chance
                                # of being queried.
        ip =    198.41.0.4
        ,       192.228.79.201
        ,       192.33.4.12
        ,       128.8.10.90
        ,       192.203.230.10
        ,       192.5.5.241
        ,       192.112.36.4
        ,       128.63.2.53
        ,       192.36.148.17
        ,       192.58.128.30
        ,       193.0.14.129
        ,       198.32.64.12
        ,       202.12.27.33
        ;
        timeout = 5;
        uptest = query;         # Test availability using empty DNS queries.
        interval = 30m;         # Test every half hour.
        ping_timeout = 300;     # Test should time out after 30 seconds.
        purge_cache = off;
        exclude = .localdomain;
        policy = included;
        preset = off;
}
*/
&nbsp;
source {
        owner=localhost;
#       serve_aliases=on;
        file=&quot;/etc/hosts&quot;;
}
&nbsp;
rr {
        name=localhost;
        reverse=on;
        a=127.0.0.1;
        owner=localhost;
        soa=localhost,root.localhost,42,86400,900,86400,86400;
}
&nbsp;
/*
neg {
        name=doubleclick.net;
        types=domain;   # This will also block xxx.doubleclick.net, etc.
}
*/
&nbsp;
/*
neg {
        name=bad.server.com;   # Badly behaved server you don't want to connect to.
        types=A,AAAA;
}
*/</pre></div></div>

<p>将客户机的dns 服务器全部设为 192.168.0.254 让所有dns请求都从这里转发。</p>
<p>其他设置<br />
关闭IPV6</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;"># echo 'alias ipv6 off' &amp;gt;&amp;gt; /etc/modprobe.conf</pre></div></div>

<p>arp 绑定<br />
网吧环境下arp 绑定是一定要做的，在确认没有arp 病毒情况下，客户机全开运行一下命令</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;">＃nmap -sP 192.168.0.0/24
＃cat /proc/net/arp | awk '{print $1 &quot; &quot; $4}' |sort -t. -n +3 -4 &gt; /etc/ethers
＃echo &quot;arp -f&quot; &gt;&gt; /etc/rc.local</pre></div></div>

<p>一个管理用 shell<br />
网吧像很多局域网环境一样非常痛恨那些恶意使用p2p ，在有人恶意使用p2p 工具是要能够及时找到它。<br />
创建一个top5.sh 内容为</p>

<div class="wp_syntax"><div class="code"><pre class="bansh" style="font-family:monospace;">#!/bin/bash
cat /proc/net/ip_conntrack | cut -d ' ' -f 10 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 5</pre></div></div>

<p>在怀疑有人狂开p2p 的时候运行该脚本，可以列出打开会话数最高的前五个机子的IP 和打开的会话数。</p>
<p>同时最有用的管理命令<br />
iftop 可以查看内网机子的即时流量</p>
<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/wang-ba-linux-wang-guan-she-zhi-ji-lu-bu-chong.html" title="网吧Linux 网关设置记录补充">网吧Linux 网关设置记录补充</a></li><li><a href="http://www.linuxbyte.org/squid-tou-ming-dai-li-you-hua.html" title="Squid 透明代理优化">Squid 透明代理优化</a></li><li><a href="http://www.linuxbyte.org/refreshpattern-xue-xi-fan-li.html" title="refresh_pattern 学习范例">refresh_pattern 学习范例</a></li><li><a href="http://www.linuxbyte.org/guan-yu-squid-de-yi-xie-ji-lu.html" title="关于squid的一些记录">关于squid的一些记录</a></li><li><a href="http://www.linuxbyte.org/squid-xian-zhi-yong-hu-bing-fa-lian-jie-shu-2.html" title="Squid 限制用户并发连接数">Squid 限制用户并发连接数</a></li><li><a href="http://www.linuxbyte.org/%e5%8d%87%e7%ba%a7squid-26-%e5%88%b027-%e7%9a%84%e5%86%a4%e6%9e%89%e8%b7%af.html" title="升级squid 2.6 到2.7 的冤枉路">升级squid 2.6 到2.7 的冤枉路</a></li><li><a href="http://www.linuxbyte.org/squid-unofficial-support-for-rhelcentos.html" title="Squid unofficial support for RHEL/CentOS">Squid unofficial support for RHEL/CentOS</a></li><li><a href="http://www.linuxbyte.org/wang-ba-mei-ip-xian-su-bu-chong-squid-xian-su.html" title="网吧每IP 限速补充（squid 限速）">网吧每IP 限速补充（squid 限速）</a></li><li><a href="http://www.linuxbyte.org/iptables%ef%bc%8dtc-wang-ba-mei-ip-xian-su-jiao-ben.html" title="Iptables＋tc 网吧每IP 限速脚本">Iptables＋tc 网吧每IP 限速脚本</a></li><li><a href="http://www.linuxbyte.org/yong-iptables-er-fei-tc-xian-zhi-liu-liang.html" title="用Iptables 而非tc 限制流量">用Iptables 而非tc 限制流量</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html">网吧Linux 网关设置记录</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/dns-cache" rel="tag">dns cache</a>, <a href="http://www.linuxbyte.org/tag/iptables" rel="tag">iptables</a>, <a href="http://www.linuxbyte.org/tag/nat" rel="tag">nat</a>, <a href="http://www.linuxbyte.org/tag/pdnsd" rel="tag">pdnsd</a>, <a href="http://www.linuxbyte.org/tag/squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e8%80%8c%e4%b8%94" rel="tag">而且</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" rel="tag">透明代理</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/dns-cache" title="dns cache" rel="tag">dns cache</a>, <a href="http://www.linuxbyte.org/tag/iptables" title="iptables" rel="tag">iptables</a>, <a href="http://www.linuxbyte.org/tag/nat" title="nat" rel="tag">nat</a>, <a href="http://www.linuxbyte.org/tag/pdnsd" title="pdnsd" rel="tag">pdnsd</a>, <a href="http://www.linuxbyte.org/tag/squid" title="squid" rel="tag">squid</a>, <a href="http://www.linuxbyte.org/tag/%e8%80%8c%e4%b8%94" title="而且" rel="tag">而且</a>, <a href="http://www.linuxbyte.org/tag/%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86" title="透明代理" rel="tag">透明代理</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/linux-iptables-nat-squid-pdnsd.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

