📄 1517.html
字号:
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=100
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=98
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=79
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=103
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=26
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR>
<TR>
<TD colSpan=3><A title=linux知识宝库
href="index.html" tppabs="http://www.linuxhero.com/docs/index.html"><IMG height=83
src="images/header_r1_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c1.gif" width=472 border=0
name=header_r1_c1></A></TD>
<TD colSpan=3>
<form action="http://www.linuxhero.com/docs/search.html" method=get>
<table
style="BORDER-RIGHT: #c4c4c4 1px solid; BORDER-TOP: #c4c4c4 1px solid; BORDER-LEFT: #c4c4c4 1px solid; BORDER-BOTTOM: #c4c4c4 1px solid"
cellspacing=0 cellpadding=3 width="95%" border=0 align="center">
<tbody>
<tr>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif">
<div align=center><font class=normalfont>搜索文章:
<input type=hidden value=result name=action2>
<input type=radio checked value=title name=type>标题
<input type=radio value=content name=type>内容
<input type=image src="images/button_go.gif" tppabs="http://www.linuxhero.com/docs/images/button_go.gif" border=0 name=image2>
</font></div>
</td>
</tr>
<tr>
<td noWrap>
<div align="center">
<input maxlength=100 size=30 name=keyword2>
</div>
</td>
</tr></tbody>
</table>
</form>
</TD>
<TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
<TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<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内核的透明代理解决方案B</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:作者<br>来自:Linux知识宝库<br>联系方式:无名<br><br> 摘要:该文讨论了如何在Linux2.4环境下如何通过iptables和squid实现透明代理。<br>
<br>
硬件环境:联想奔月 双网卡<br>
<br>
软件环境:kernel 2.4.7 squid-2.4.STABLE1<br>
<br>
1.什么是代理服务器?<br>
<br>
所谓代理服务器是指代表内部私有网中的客户连接互联网www资源的外部服务器的程序。客户与代理服务器对话,它们接收客户请求,然后连接真实的服务器,请求得到数据并将响应数据返回给客户。代理服务器发挥了中间转接作用。<br>
<br>
在代理方式下,私有网络的数据包从来不能直接进入互联网,而是需要经过代理的处理。同样,外部网的数据也不能直接进入私有网,而是要经过代理处理以后才能到达私有网,因此在代理上就可以进行访问控制,地址转换等功能。目前,代理服务器软件有很多,如 Netscape Suit Proxy,MS Proxy,Wingate,squid等。这些代理服务器不仅能起到防火墙的作用,而且还可以加速局域网用户对INTERNET的访问,因为代理服务器有一个大的缓冲器,将每次浏览的网页都保存起来,在下一次访问该页时就直接从缓冲器里调出,而无需再次访问原始服务器。<br>
<br>
2.什么是透明代理?<br>
<br>
透明代理技术中的透明是指客户端感觉不到代理的存在,不需要在浏览器中设置任何代理,客户只需要设置缺省网关,客户的访问外部网络的数据包被发送到缺省网关,而这时缺省网关运行有一个代理服务器,数据实际上被被重定向到代理服务器的代理端口(如8080),即由本地代理服务器向外请求所需 数据然后拷贝给客户端。理论上透明代理可以对任何协议通用。<br>
<br>
但是在这种情况下客户端必须正确设置DNS服务器。因为现在浏览器不设置任何代理。则DNS查询必须由browser来解析,也就是要由客户端必须在TCP/IP中设置的正确的DNS服务器,其完成dns解析。<br>
<br>
例如: 从私有网络上访问因特网上的 web 站点。<br>
<br>
私有网地址为192.168.1.*, 其中客户机是192.168.1.100,防火墙机器网卡是192.168.1.1。透明web代理被安装在防火墙机器上并配置端口为8080。内核使用 iptables把与防火墙端口80的连接重定向到代理服务。私有网上的Netscape被配置为直接连接方式。私有网络的客户机需要设置DNS服务器。私有网络上机器的默认路由(别名网关)指向防火墙机器。客户机机器上的 Netscape 访问 http://slashdot.org。<br>
<br>
1.Netscape通过查找"slashdot.org", 得到它的地址为207.218.152.131. 然后它使用端口1050与此地址建立一个连接,并向web站点发出请求。<br>
<br>
2.当包由客户机 (port 1050)通过防火墙送往slashdot.org(port 80)时, 它们重定向到代理服务重定的8080端口。透明代理使用端口1025与207.218.152.131的端口80(这是原始包的目的地址)建立一个连接。<br>
<br>
3. 当代理服务收到从 web 站点传来的页面后, 通过已经建立的连接把它复制给 Netscape。<br>
<br>
4. Netscape 显示此页面。<br>
<br>
5. 从slashdot.org 的角度来看,连接是由1.2.3.4(防火墙的拨号连接IP地址)的端口1025到 207.218.152.131的端口80。从客户机的角度来看,连接是从192.168.1.100(客户机)端口1050连接到207.218.152.131(slashdot.org)的端口80, 但是, 它实际是在与透明代理服务器对话。<br>
<br>
这就是透明代理的操作流程。<br>
<br>
3.内核编译<br>
<br>
一般来讲,透明代理所在机器往往是带动整个局域网联入互联网的入口,因此该机器往往需要配置防火墙规则以对内部网络进行防护。因此在编译内核时也许要考虑将防火墙支持选项编译进去。一般来说需要在使用make menuconfig命令配置时打开如下选项:<br>
<br>
[*]Networking support <br>
[*]Sysctl support <br>
[*]Network packet filtering <br>
[*]TCP/IP networking <br>
[*]/proc filesystem support <br>
[*] Kernel/User netlink socket <br>
[*] Netlink device emulation <br>
[*] Connection tracking (required for masq/NAT) <br>
[*] FTP protocol support<br>
[*] IP tables support (required for filtering/masq/NAT)<br>
<*> limit match support <br>
[*] MAC address match support <br>
[*] Netfilter MARK match support<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -