⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1516.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<A href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</A>                 | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
            </TD>
          <TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 
        border=0></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff 
        border=0>
         <TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
              
              <TR>
                <TD vAlign=top align=middle width="60%">
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" 
                  background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
                    <TBODY>
                    <TR>
                        <TD vAlign=top width="80%"> 
                          <DIV align=center>
                        <FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
                            </FORM>
                        <TABLE cellSpacing=0 cellPadding=0 width="95%" 
                          border=0><TBODY>
                          <TR>
                            <TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif" 
                          height=30></TD></TR></TBODY></TABLE>
                        <TABLE cellSpacing=0 cellPadding=3 width="95%" 
                        align=center border=0>
                          <TBODY>
                          <TR>
                            <TD>
                              <TABLE cellSpacing=0 cellPadding=3 width="100%" 
                              border=0>
                                <TBODY>
                                <TR>
                                      <TD vAlign=top> 
<p><FONT class=normalfont><B><font color=blue>基于Linux2.4内核的透明代理配置方案A</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:seraphim@itpub.net<br>来自:Linux知识宝库<br>联系方式:无名<br><br>Date: 2003.08<br>
<br>
环境:<br>
服务器: SuSE Linux 8.2 + ADSL<br>
客户端: Windows2000<br>
局域网: 用8口10-100M集线器连接SuSE(192.168.1.3), Windows(192.168.1.5), ADSL(192.168.1.1)<br>
<br>
使用squid+iptables,大部分经验从www.linuxaid.com得到,只是在这里总结一下。<br>
<br>
关于iptables的详细说明,请看:<br>
IPTABLES HOWTO<br>
http://www.telematik.informatik.uni-karlsruhe.de/lehre/seminare/LinuxSem/downloads/netfilter/iptables-HOWTO.html<br>
<br>
关于iptables配置工具,请看:<br>
knetfilter:<br>
http://expansa.sns.it/knetfilter<br>
g-Shield:<br>
http://muse.linuxmafia.org/gshield.html<br>
<br>
关于squid优化,请看:<br>
squid优化完全手册1:<br>
http://www.linuxaid.com.cn/articles/2/8/289179080.shtml<br>
squid优化完全手册2:<br>
http://www.linuxaid.com.cn/articles/5/4/546967373.shtml<br>
<br>
关于iptables防火墙的配置,请看:<br>
用iptales实现包过虑型防火墙(一):<br>
http://www.linuxaid.com.cn/engineer/bye2000/doc/iptables1.htm <br>
用iptales实现包过虑型防火墙(二):<br>
http://www.linuxaid.com.cn/engineer/bye2000/doc/iptables2.htm<br>
<br>
好,下面开始配置。<br>
<br>
先解释为什么要配置透明代理。 <br>
其实只配置squid就可以实现代理功能,但是对于客户端,就必须在浏览器中设置proxy server,对于其他的工具,比如FlashGet, CuteFTP等等,也必须一一设置,这一点非常麻烦。但是如果设置了透明代理,那么在客户端只需要在网络配置中设置一个网关就可以了,其他的任何程序都不用另行设置。这是设置透明代理最大的诱惑,当然这只是对我而言,其实iptables有更强大的防火墙功能,这才是它最大的用处。但是,此次配置不涉及防火墙,如果有兴趣的请看上贴的iptables howto。 <br>
<br>
1。假设我们的linux内已经将防火墙支持选项编译进去,这一点可以进入kernel source目录,用make menuconfig确认。 <br>
<br>
2。安装squid,一般对于各个Linux发行版,完全安装的话应该已经安装过了,当然也可以从以下网址下载安装: <br>
http://www.squid-cache.org/ <br>
<br>
3。无论是重新安装的还是系统中原来就有的,因为对于各个发行版可能squid的配置文件所在的位置各不相同,用find命令确认squid.conf文件的确切位置。如果是rpm安装,也可以用rpm命令来确认:rpm -ql [squidrpmname.rpm] | grep squid.conf <br>
<br>
4。编辑squid.conf文件,确保以下内容存在: <br>
httpd_accel_host virtual <br>
httpd_accel_port 80 <br>
httpd_accel_with_proxy on <br>
httpd_accel_uses_host_header on <br>
cache_effective_user nobody <br>
cache_effective_group nobody <br>
http_access allow all <br>
cache_dir ufs /usr/local/squid/cache 100 16 256 <br>
注:最后一句为cache目录,需要在下面创建,可以改为你本机squid的所在目录。倒数第二句,表示我们允许所有的请求,这是很不安全的,可以自己创建一个组,然后allow这个组,并且deny all,具体的设置仔细看一下squid.conf就可以了,有很详细的解释和例子 <br>
<br>
5。创建cache目录(如果没有的话),修改该目录所有者为nobody <br>
chown nobody:nobody /pathname/cache <br>
<br>
6。查看配置文件中默认的log目录,将那个目录的所有者修改为nobody,以确保log可以写入 <br>
<br>
7。创建cache: squid -z <br>
<br>
8。启动squid: squid -D <br>
squid的站点维护了一份很详细的FAQ,基本上你需要问的问题都有答案,比如你可以先用squid -NCd1来以debug模式启动,这样如果有错误会报出来,一般如果是ADSL拨号的,那么在没有拨号之前就启动squid的话是会出错的 (FATAL: ipcache_init: DNS name lookup tests failed),因为squid启动时会去检查一些常用的DNS,但是这时候你并没有接入internet,自然就出错了,所以我们需要在启动的时候不检查DNS,这就需要用加上-D选项来启动squid <br>
<br>
9。启动成功之后,我们就可以去客户端的浏览器里面设置proxy来测试一下了,如果可以接入internet,那么squid就算设置成功了 <br>
<br>
10。还有一个后续工作,就是确认squid是不是开机就自动启动了,一般在/etc/init.d中已经有了squid脚本,我们需要做的就是将它ln到适当的rc.d目录中,比如我默认是runlevel5启动的,那么我执行: <br>
ln -s /etc/init.d/squid /etc/init.d/rc5.d/S99squid <br>
ln -s /etc/init.d/squid /etc/init.d/rc5.d/K01squid <br>
这是在SuSE下面,如果是RedHat,那么rc.d目录是在/etc下面,而不是在/etc/init.d下面。 <br>
<br>
OK,squid设置结束了,下面我们开始配置iptables<br>
可以用前面所提到的配置工具,但是我没有试过,所以是直接用iptables命令来做的。 <br>
可以man iptables来查看帮助 <br>
<br>
我们把iptables的设置命令存在一个脚本文件中,假设脚本文件名为firewall,然后将此文件存放在/etc/init.d中,并且在启动文件中运行此脚本。以下为操作步骤 <br>
<br>
1。touch /etc/init.d <br>
<br>
2。vi /etc/init.d <br>
加入以下内容:<br>
#!/bin/sh<br>
echo "Enabling IP Forwarding..."<br>
echo 1 &gt; /proc/sys/net/ipv4/ip_forward<br>
echo "Starting iptables rules..."<br>
#Refresh all chains<br>
/sbin/iptables -F -t nat<br>
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp<br>
--dport 80 -j REDIRECT --to-ports 3128<br>
<br>
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o <br>
ppp0 -j MASQUERADE<br>
<br>
对于以上命令的解释如下: <br>
/proc/sys/net/ipv4/ip_forward必须设置为1(默认是0)才可以使用路由功能。 <br>
/sbin/iptables -F -t nat将nat table中的所有现存规则清空。 <br>
eth0:为Linux机器中的网卡。 <br>
3128:为squid中默认的监听端口。 <br>
ppp0:为linux中的ADSL设备(在SuSE中为ppp0,在redhat中可能是dsl0)。 <br>
MASQUERADE:适用于拨号上网的服务器,因为没有静态IP地址,对于有静态IP的服务器,可以用SNAT --to-source ipadress来替代。 <br>
<br>
注:以上的命令没有涉及防火墙,请自行参考配置,以上命令也没有删除filter table中的规则,也就是如果以前设置过防火墙,那么不会受到影响。 <br>
<br>
3。chmod u+x firewall,更改文件属性,使其可以被执行 <br>
<br>
4。编辑/etc/init.d/boot.local文件,在最后加上/etc/init.d/firewall这一句,确保开机就执行此脚本。 <br>
注:SuSE中是boot.local,对于redhat,则需要编辑/etc/rc.d/rc.local文件。 <br>
<br>
5。运行firewall,规则立刻生效。 <br>
<br>
到此为止,所有配置结束。<br>
</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -