<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[IDC笔记 - GNU/Linux]]></title>
<link>http://www.idcnote.com/</link>
<description><![CDATA[创造机会的人是勇者；等待机会的人是愚者]]></description>
<language>zh-cn</language>
<copyright><![CDATA[Copyright 2005 PBlog2 v2.4]]></copyright>
<webMaster><![CDATA[wentaiyou@126.com(Kevin)]]></webMaster>
<generator>PBlog2 v2.4</generator> 
<image>
	<title>IDC笔记</title> 
	<url>http://www.idcnote.com/images/logos.gif</url> 
	<link>http://www.idcnote.com/</link> 
	<description>IDC笔记</description> 
</image>

			<item>
			<link>http://www.idcnote.com/default.asp?id=63</link>
			<title><![CDATA[AWK的用法]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Fri,19 Mar 2010 15:36:30 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=63</guid>	
		<description><![CDATA[cat date<br/>a 1<br/>b 9<br/>c 1<br/>d 1<br/>e 3<br/>f 3<br/>g 1<br/><br/>date的内容为上。<br/>如何打印出第二列最大的行<br/>awk &#39;NR==FNR{t=(t&gt;$2)?t:$2}NR&gt;FNR&amp;&amp;$NF==t&#39; date date]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=61</link>
			<title><![CDATA[shell编程IF的基本用法]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Tue,23 Feb 2010 12:41:49 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=61</guid>	
		<description><![CDATA[1 字符串判断 <br/><br/>str1 = str2　　　　　　当两个串有相同内容、长度时为真<br/>str1 != str2　　　　　 当串str1和str2不等时为真<br/>-n str1　　　　　　　 当串的长度大于0时为真(串非空)<br/>-z str1　　　　　　　 当串的长度为0时为真(空串)<br/>str1　　　　　　　　&nbsp;&nbsp; 当串str1为非空时为真<br/><br/>2 数字的判断 <br/><br/>int1 -eq int2　　　　两数相等为真<br/>int1 -ne int2　　　　两数不等为真<br/>int1 -gt int2　　　　int1大于int2为真<br/>int1 -ge int2　　　　int1大于等于int2为真<br/>int1 -lt int2　　　　int1小于int2为真<br/>int1 -le int2　　　　int1小于等于int2为真<br/><br/>3 文件的判断 <br/><br/>-r file　　　　　用户可读为真<br/>-w file　　　　　用户可写为真<br/>-x file　　　　　用户可执行为真<br/>-f file　　　　　文件为正规文件为真<br/>-d file　　　　　文件为目录为真<br/>-c file　　　　　文件为字符特殊文件为真<br/>-b file　　　　　文件为块特殊文件为真<br/>-s file　　　　　文件大小非0时为真<br/>-t file　　　　　当文件描述符(默认为1)指定的设备为终端时为真<br/><br/>3 复杂逻辑判断 <br/><br/>-a 　 　　　　　 与<br/>-o　　　　　　　 或<br/>!　　　　　　　　非<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=59</link>
			<title><![CDATA[MMAP LIBPCAP]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Wed,28 Oct 2009 16:21:07 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=59</guid>	
		<description><![CDATA[<a href="http://public.lanl.gov/cpw/" target="_blank">http://public.lanl.gov/cpw/</a> <br/><a target="_blank" href="http://soft.idcnote.com/linux/libpcap-0.9.8.20081128.tar.gz">下载板本</a><br/>以上有清楚的介绍及安装.<br/><br/>rpm -e&nbsp;&nbsp; --nodeps&nbsp;&nbsp;libpcap-*&nbsp;&nbsp;先要删除原先系统上的PCAP可以通过RPM -QA来查看<br/><br/><br/>cd /tmp<br/>tar -zxf /tmp/libpcap-0.9.8.20081128.tar.gz<br/>ln -s libpcap-0.9.8.20081128 libpcap<br/>cd libpcap<br/>sh bootstrap<br/>Hopefully, you have installed: libtool automake autoconf flex bison<br/>If you have problems, rm -rf config and re-issue the bootstrap program<br/>Ok to proceed?[N/y] y<br/><br/> ./configure --prefix=/usr --enable-shared<br/>make clean<br/>make install<br/>ldconfig<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=56</link>
			<title><![CDATA[bonding linux下多网卡的汇聚]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Sat,12 Sep 2009 12:14:51 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=56</guid>	
		<description><![CDATA[说明：<br/>绑定多块网卡为一个虚拟ip，类似csico的etherchannel，实现冗余或负载均衡和增加带宽的功能。<br/>内核需要bonding的支持，察看是否挂在bonding，lsmod命令。默认2.6内核中bonding已经被编译为M的选项，不需重新编译内核。<br/><br/>其实Redhat关于bond，在kernel-doc里有一篇文档，讲述得非常详细，可以先看看/usr/share/doc/kernel-doc-2.6.18/Documentation/networking/bonding.txt<br/><br/>一：不需重起的配置方法。<br/>1 modprobe bonding miimon=100<br/>2 ifconfig bond0 192.168.1.1 netmask 255.255.255.0<br/>3 ifenslave bond0 eth0 eth1<br/>(这个办法比较简单.可以写个脚本然后放在/ETC/RC.LOCAL中让他开机运行.要记的加上<br/>route add default gw x.x.x.x)<br/><br/><br/>小案例:<br/>echo &#34;/etc/mybonding&#34; &gt;&gt; /etc/rc.local<br/><br/>echo &#39;#!/bin/bash&#39;&nbsp;&nbsp;&gt; /etc/mybonding<br/>echo &#34;#&#34;&nbsp;&nbsp;&gt;&gt; /etc/mybonding<br/>echo &#34;modprobe bonding miimon=100 mode=0&#34;&nbsp;&nbsp;&gt;&gt; /etc/mybonding<br/>echo &#34;ifconfig bond0 MY_IP netmask MY_NETMASK&#34;&nbsp;&nbsp;&gt;&gt; /etc/mybonding<br/>echo &#34;ifenslave bond0 eth0 eth1&#34;&nbsp;&nbsp;&gt;&gt; /etc/mybonding<br/>echo &#34;route add default gw MY_DEFAULT_ROUTE&#34;&nbsp;&nbsp;&gt;&gt; /etc/mybonding<br/><br/>chmod 700 /etc/mybonding<br/><br/>mv /etc/sysconfig/network-scripts/ifcfg-eth0&nbsp;&nbsp;/etc/sysconfig/network-scripts/bak.ifcfg-eth0<br/>mv /etc/sysconfig/network-scripts/ifcfg-eth1&nbsp;&nbsp;/etc/sysconfig/network-scripts/bak.ifcfg-eth1<br/><br/>echo &#34;DEVICE=eth0&#34; &gt; /etc/sysconfig/network-scripts/ifcfg-eth0 <br/>echo &#34;BOOTPROTO=static&#34; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth0 <br/>echo &#34;ONBOOT=yes&#34; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth0<br/><br/>echo &#34;DEVICE=eth1&#34; &gt; /etc/sysconfig/network-scripts/ifcfg-eth1<br/>echo &#34;BOOTPROTO=static&#34; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth1<br/>echo &#34;ONBOOT=yes&#34; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth1 <br/><br/><br/><br/>二：重起仍然生效的配置方法一。<br/>1关闭要绑定的物理网卡<br/>修改ifcfg-eth0和ifcfg-eth1的启动项<br/><br/>BOOTPROTO=none<br/>ONBOOT=no<br/><br/>2建立虚拟网卡<br/><br/>在/etc/sysconfig/network-scripts/ 目录下建立 ifcfg-bond0，并修改 /etc/modprobe.conf文件实现开机自动挂载。<br/><br/>/etc/sysconfig/network-scripts/ifcfg-bond0 配置如下：<br/><br/>DEVICE=bond0<br/>IPADDR=192.168.0.193<br/>NETMASK=255.255.255.0<br/>BOOTPROTO=static<br/>ONBOOT=yes<br/>GATEWAY=192.168.0.3<br/><br/>/etc/modprobe.conf 配置如下：<br/>alias eth0 bnx2<br/>alias eth1 bnx2<br/>alias bond0 bonding<br/>options bonding miimon=100 mode=1（miimon是用来进行链路监测的。 <br/>比如:miimon=100，那么系统每100ms监测一次链路连接状态，如果有一条线路不通就转入另一条线路。模式1为主备模式，模式0为负载均衡与增加带宽的模式）<br/>注：以上为只做一组bonding的方式，如果做多组的话可以更改为以下的方式：<br/>alias eth0 bnx2<br/>alias eth1 bnx2<br/>alias eth2 e1000<br/>alias eth3 e1000<br/>install bond0 /sbin/modprobe -a eth0 eth1 &amp;&amp; /sbin/modprobe bonding<br/>alias bond0 bonding<br/>install bond1 /sbin/modprobe -a eth2 eth3 &amp;&amp; /sbin/modprobe bonding<br/>alias bond1 bonding<br/>options bonding mode=1 miimon=100 max_bonds=2<br/><br/>最后执行测试， REBOOT确认bond0是否启动，如果启动，配置成功。<br/><br/><br/>查看bonding状态<br/>cat /proc/net/bonding/bond0<br/><br/><br/>三：重起仍然生效的配置方法二<br/>1 vi /etc/sysconfig/network-scripts/ifcfg-bond0<br/>DEVICE=bond0<br/>IPADDR=192.168.0.193<br/>NETMASK=255.255.255.0<br/>BOOTPROTO=static<br/>ONBOOT=yes<br/>GATEWAY=192.168.0.3<br/><br/><br/>2 vi /etc/sysconfig/network-scripts/ifcfg-eth0<br/>DEVICE=eth0<br/>BOOTPROTO=none<br/>ONBOOT=yes<br/>MASTER=bond0<br/>SLAVE=yes<br/><br/>3 vi /etc/sysconfig/network-scripts/ifcfg-eth1<br/>DEVICE=eth1<br/>BOOTPROTO=none<br/>ONBOOT=yes<br/>MASTER=bond0<br/>SLAVE=yes<br/><br/>4 vi /etc/modprobe.conf<br/><br/>alias bond0 bonding<br/>options bonding miimon=100 mode=1<br/><br/>5 reboot<br/><br/><br/><br/><br/>四： Linux 的 BONDING 模式<br/><br/>bonding 的应用分为合并网卡提高带宽与冗余两种功能。<br/><br/>在 linux kernel bonding 的 kernel module 內，可以依据传入 mode=X 的方式来决定运行模式，其中数值可能結果依据官方文件说明如下：<br/><br/>mode=0 (balance-rr)<br/><br/>Round-robin policy: Transmit packets in sequential o&#114;der from the first available <br/>slave through the last. This mode provides load balancing and fault tolerance.<br/><br/>mode=1 (active-backup)<br/><br/>Active-backup policy: Only one slave in the bond is active. A different slave <br/>becomes active if, and only if, the active slave fails. The bond&#39;s MAC address is externally visible on only one port <br/><br/>(network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior <br/><br/>of this mode.<br/><br/>mode=2 (balance-xor)<br/><br/>XOR policy: Transmit based on [(source MAC address XOR&#39;d with destination <br/>MAC address) modulo slave count]. This sel&#101;cts the same slave for each destination MAC address. This mode provides load <br/><br/>balancing and fault tolerance.<br/><br/>所以可以依据实际需求決定要使用哪种模式来提供 bonding 功能。一般所谓合并与平衡负载功能部份，选择 mode=0，而若是要达成 active-backup 架构的話，則选择使用 mode=1 即可,注意，网卡需要支持mii-tool<br/><br/>设定配置文件， /etc/modprobe.conf 放置如下內容即可决定类型：<br/><br/>alias bond0 bonding<br/>options bond0 miimon=100 mode=1<br/><br/>说明：miimon 是用来进行链路监测的。如果miimon=100，那么系统每100ms 监测一次链路连接状态，如果有一条线路不通就转入另一条线路；mode 的值表 示工作模式，它共有0，1，2，3四种模式，常用的为0，1两种。<br/>mode=0 表示load balancing (round-robin)为负载均衡方式，两块网卡都工作。<br/>mode=1 表示fault tolerance (active-backup)提供冗余功能，工作方式是主备的工作方式，也就是说默认情况下只有一块网卡工作，另一块做备份。<br/>max_bonds=2 表示最大的网卡绑定数量为2。]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=55</link>
			<title><![CDATA[LINUX下CONSOLE口连接工具]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Fri,28 Aug 2009 12:23:15 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=55</guid>	
		<description><![CDATA[1.minicom的执行<br/>用指令&#34;rpm -qa | grep minicom&#34;来确认是否安装了minicom，回车后会显示minicom 的版本信息．<br/>第一次 启动时：<br/>即输入 minicom提示 错误。则 需： minicom -s<br/>启动<br/>出现配置菜单：选serial port setup<br/>进入串口配置<br/>输入A配置串口驱动为/dev/ttyS0<br/>输入E配置速率为115200 8N1<br/>输入F将 Hardware Flow Control 设 为 NO<br/>回车 退出<br/>由于我们使用minicom作为超级终端控制路由器等设备, 而不是控制modem, 所以需要修改Modem and<br/><br/>dialing, 将Init string, Reset string, Hang-up string设置为空. 设置完成后选择Save setup as<br/><br/>dfl将当前设置保存为默认设置.<br/>在配置菜单 选Save setup as xyz保存（一定要记得这一步）<br/>选Exit退出<br/><br/>下次在输入minicon&nbsp;&nbsp;xyz即可直接进入。<br/>命令minicom是进入串口超级终端画面，而minicom -s为配置minicom。<br/>说明/dev/ttyS0 对应为串口0 为你连接开发板的端口。<br/><span style="color:Red">注意：非正常关闭minicom，会在/var/lock下创建几个文件LCK*，这几个文件阻止了minicom的运行，将<br/><br/>它们删除后即可恢复使用 </span><br/>]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=51</link>
			<title><![CDATA[LINUX内核学习-0.11]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Mon,20 Jul 2009 20:33:59 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=51</guid>	
		<description><![CDATA[第一天.看的眼花什么都没看明白.只是下了一堆软件.乱搞了一团.最后0.11板真的起来了.一个简单的系统.哎看来离系统还很远.继续中.....]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=50</link>
			<title><![CDATA[LINUX内核学习]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Fri,10 Jul 2009 16:17:57 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=50</guid>	
		<description><![CDATA[<a href="http://oldlinux.org/Linux.old/kernel/" target="_blank">http://oldlinux.org/Linux.old/kernel/</a><br/>早期LINUX的内核源码.]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=45</link>
			<title><![CDATA[LINUX作双路由(策略路由)]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Thu,25 Jun 2009 22:28:04 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=45</guid>	
		<description><![CDATA[<p>&nbsp;</p>
<p>自己动手做了一个过程如下:</p>
<p>安装服务器AS4-32系统.然后配置要的IP</p>
<p>本服务器有三个网卡口<br />名称&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 网关IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />eth0&nbsp;&nbsp; 192.168.1.1&nbsp;&nbsp;&nbsp; 无&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //这个作为内网用&nbsp;<br />eth1&nbsp;&nbsp;&nbsp;A.A.A.A&nbsp;&nbsp;&nbsp; &nbsp; A.A.A.1&nbsp;&nbsp; <br />eth2&nbsp;&nbsp;&nbsp;&nbsp;B.B.B.B&nbsp;&nbsp;&nbsp;&nbsp;B.B.B.1</p>
<p>修改/etc/iproute2/ rt_table<span class="t_tag" onclick="tagshow(event)">文件</span>,建立路由表对应关系.具体文件格式如下: <br /><br /># reserved values <br /># <br />255 local <br />254 main <br />253 default <br />0&nbsp; &nbsp;unspec <br />100 shangdu <br /># <br /># local <br /># <br />#1&nbsp;&nbsp;inr.ruhep</p>
<p>写一个脚本/etc/myroute</p>
<p>#!/bin/sh <br />echo &quot;1&quot; &gt; /proc/sys/net/ipv4/ip_forward <br />/sbin/modprobe ip_conntrack_ftp <br />/sbin/modprobe ip_nat_ftp</p>
<p>/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE <br />/sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE<br />/sbin/iptables -t mangle -A PREROUTING&nbsp; -p icmp&nbsp; -s 192.168.1.0/24 -j MARK --set-mark 6</p>
<p>ip route add 0/0 via A.A.A.1<br />ip route add 0/0 via B.B.B.1 table 100</p>
<p>ip rule add fwmark 6 table 100<br />ip rule add to 202.96.0.0/16 table 100<br />&nbsp;&nbsp; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>网上参考资料1:</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>一、环境和要求： </p>
<p>线路:&nbsp; 内网百兆网络1:&nbsp; eth0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 192.168.1.1&nbsp;&nbsp; 100Mbit </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 电信百兆光纤1:&nbsp; eth1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 222.88.1.1&nbsp;&nbsp;&nbsp;&nbsp; gateway&nbsp;&nbsp; 222.88.1.2&nbsp;&nbsp;&nbsp; 100Mbit </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 网通百兆光纤1 :&nbsp; eth2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 218.28.1.1&nbsp;&nbsp;&nbsp;&nbsp; gateway&nbsp;&nbsp; 218.28.1.2&nbsp;&nbsp;&nbsp; 100Mbit&nbsp;&nbsp; </p>
<p>操作系统: Red Hat Enterprise AS 5 </p>
<p><br />二、 网络要求： </p>
<p>业务需求:&nbsp;&nbsp; 一.&nbsp;&nbsp; 双线策略路由,网通IP走网通网关,电信IP走电信网关. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 二.&nbsp;&nbsp; 网内所有主机ARP绑定 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 三.&nbsp;&nbsp; TC流量控制, 根据提供服务不同,走相应的策略. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />三、具体步骤: </p>
<p>1.&nbsp;&nbsp;&nbsp; linux安装这里不多介绍,网上的教程很多.装完之后配置IP地址,满足上面的线路需求即可.(注:安装时尽量不要配置gateway,会和iproute2有冲突) </p>
<p>2.&nbsp; 打开内核IP转发机制:&nbsp; echo &quot;1&quot; &gt; /proc/sys/net/ipv4/ip_forward </p>
<p>3.&nbsp;&nbsp;&nbsp; SNAT地址转换: <br />iptables -t nat -A POSTROUTING -s 192.168.0.0/22 -o eth1 -j MASQUERADE <br />iptables -t nat -A POSTROUTING -s 192.168.0.0/22 -o eth2 -j MASQUERADE </p>
<p><br />4.&nbsp;&nbsp;&nbsp; 修改/etc/iproute2/ rt_table文件,建立路由表对应关系.具体文件格式如下: </p>
<p># reserved values <br /># <br />255 local <br />254 main <br />253 default <br />0&nbsp;&nbsp; unspec <br />100 shangdu <br /># <br /># local <br /># <br />#1&nbsp; inr.ruhep </p>
<p>5.&nbsp; 配置电信默认路由添加到main表中: </p>
<p>ip route add 0/0 via 222.88.1.2&nbsp; dev eth1 table main </p>
<p>6.&nbsp;&nbsp;&nbsp; 新建路由表table 100,配置网通默认路由添加到100表中: </p>
<p>ip route add 0/0 via 218.28.1.2 dev eth2 table 100 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />7.&nbsp;&nbsp;&nbsp; 在table 100的路由表中添加规则.(注:包含所有的网通IP段) <br />ip rule add to 58.16.0.0/16 table 100 <br />ip rule add to 58.17.0.0/17 table 100 <br />ip rule add to 58.17.128.0/17 table 100 <br />ip rule add to 58.18.0.0/16 table 100 <br />ip rule add to 58.19.0.0/16 table 100 <br />ip rule add to 58.20.0.0/16 table 100 <br />ip rule add to 58.21.0.0/16 table 100 <br />ip rule add to 58.22.0.0/15 table 100 <br />ip rule add to 58.240.0.0/15 table 100 <br />ip rule add to 58.242.0.0/15 table 100 <br />ip rule add to 58.244.0.0/15 table 100 <br />ip rule add to 58.246.0.0/15 table 100 <br />ip rule add to 58.248.0.0/13 table 100 <br />ip rule add to 60.0.0.0/13 table 100 <br />ip rule add to 60.8.0.0/15 table 100 <br />ip rule add to 60.10.0.0/16 table 100 <br />ip rule add to 60.11.0.0/16 table 100 <br />ip rule add to 60.12.0.0/16 table 100 <br />ip rule add to 60.13.0.0/18 table 100 <br />ip rule add to 60.13.64.0/18 table 100 <br />ip rule add to 60.13.128.0/17 table 100 <br />ip rule add to 60.14.0.0/15 table 100 <br />ip rule add to 60.16.0.0/13 table 100 <br />ip rule add to 60.24.0.0/14 table 100 <br />ip rule add to 60.28.0.0/15 table 100 <br />ip rule add to 60.30.0.0/16 table 100 <br />ip rule add to 60.31.0.0/16 table 100 <br />ip rule add to 60.55.0.0/16 table 100 <br />ip rule add to 60.208.0.0/13 table 100 <br />ip rule add to 60.216.0.0/15 table 100 <br />ip rule add to 60.218.0.0/15 table 100 <br />ip rule add to 60.220.0.0/14 table 100 <br />ip rule add to 61.48.0.0/14 table 100 <br />ip rule add to 61.52.0.0/15 table 100 <br />ip rule add to 61.54.0.0/16 table 100 <br />ip rule add to 61.55.0.0/16 table 100 <br />ip rule add to 61.133.0.0/17 table 100 <br />ip rule add to 61.134.96.0/19 table 100 <br />ip rule add to 61.134.128.0/18 table 100 <br />ip rule add to 61.134.192.0/18 table 100 <br />ip rule add to 61.135.0.0/16 table 100 <br />ip rule add to 61.136.0.0/18 table 100 <br />ip rule add to 61.136.64.0/18 table 100 <br />ip rule add to 61.137.128.0/17 table 100 <br />ip rule add to 61.138.0.0/18 table 100 <br />ip rule add to 61.138.64.0/18 table 100 <br />ip rule add to 61.138.128.0/18 table 100 <br />ip rule add to 61.139.128.0/18 table 100 <br />ip rule add to 61.148.0.0/15 table 100 <br />ip rule add to 61.156.0.0/16 table 100 <br />ip rule add to 61.158.0.0/17 table 100 <br />ip rule add to 61.158.128.0/17 table 100 <br />ip rule add to 61.159.0.0/18 table 100 <br />ip rule add to 61.161.0.0/18 table 100 <br />ip rule add to 61.161.128.0/17 table 100 <br />ip rule add to 61.162.0.0/16 table 100 <br />ip rule add to 61.163.0.0/16 table 100 <br />ip rule add to 61.167.0.0/16 table 100 <br />ip rule add to 61.168.0.0/16 table 100 <br />ip rule add to 61.176.0.0/16 table 100 <br />ip rule add to 61.179.0.0/16 table 100 <br />ip rule add to 61.180.128.0/17 table 100 <br />ip rule add to 61.181.0.0/16 table 100 <br />ip rule add to 61.182.0.0/16 table 100 <br />ip rule add to 61.189.0.0/17 table 100 <br />ip rule add to 116.2.0.0/15 table 100 <br />ip rule add to 121.16.0.0/13 table 100 <br />ip rule add to 121.24.0.0/14 table 100 <br />ip rule add to 121.28.0.0/15 table 100 <br />ip rule add to 121.30.0.0/16 table 100 <br />ip rule add to 121.31.0.0/16 table 100 <br />ip rule add to 122.96.0.0/15 table 100 <br />ip rule add to 122.136.0.0/13 table 100 <br />ip rule add to 122.156.0.0/14 table 100 <br />ip rule add to 122.192.0.0/14 table 100 <br />ip rule add to 122.198.0.0/16 table 100 <br />ip rule add to 123.4.0.0/14 table 100 <br />ip rule add to 123.8.0.0/13 table 100 <br />ip rule add to 123.112.0.0/12 table 100 <br />ip rule add to 123.128.0.0/13 table 100 <br />ip rule add to 123.137.0.0/16 table 100 <br />ip rule add to 123.138.0.0/15 table 100 <br />ip rule add to 123.144.0.0/14 table 100 <br />ip rule add to 123.148.0.0/16 table 100 <br />ip rule add to 123.152.0.0/13 table 100 <br />ip rule add to 123.188.0.0/14 table 100 <br />ip rule add to 123.232.0.0/14 table 100 <br />ip rule add to 124.64.0.0/15 table 100 <br />ip rule add to 124.66.0.0/17 table 100 <br />ip rule add to 124.67.0.0/16 table 100 <br />ip rule add to 124.88.0.0/16 table 100 <br />ip rule add to 124.89.0.0/17 table 100 <br />ip rule add to 124.89.128.0/17 table 100 <br />ip rule add to 124.90.0.0/15 table 100 <br />ip rule add to 124.92.0.0/14 table 100 <br />ip rule add to 124.128.0.0/13 table 100 <br />ip rule add to 124.160.0.0/16 table 100 <br />ip rule add to 124.161.0.0/16 table 100 <br />ip rule add to 124.162.0.0/16 table 100 <br />ip rule add to 124.163.0.0/16 table 100 <br />ip rule add to 124.164.0.0/14 table 100 <br />ip rule add to 125.32.0.0/16 table 100 <br />ip rule add to 125.33.0.0/16 table 100 <br />ip rule add to 125.34.0.0/16 table 100 <br />ip rule add to 125.35.0.0/17 table 100 <br />ip rule add to 125.35.128.0/17 table 100 <br />ip rule add to 125.36.0.0/14 table 100 <br />ip rule add to 125.40.0.0/13 table 100 <br />ip rule add to 125.211.0.0/16 table 100 <br />ip rule add to 202.96.0.0/18 table 100 <br />ip rule add to 202.96.64.0/21 table 100 <br />ip rule add to 202.96.72.0/21 table 100 <br />ip rule add to 202.96.80.0/20 table 100 <br />ip rule add to 202.97.128.0/18 table 100 <br />ip rule add to 202.97.192.0/19 table 100 <br />ip rule add to 202.97.224.0/21 table 100 <br />ip rule add to 202.97.232.0/21 table 100 <br />ip rule add to 202.97.240.0/20 table 100 <br />ip rule add to 202.98.0.0/21 table 100 <br />ip rule add to 202.98.8.0/21 table 100 <br />ip rule add to 202.98.16.0/20 table 100 <br />ip rule add to 202.99.0.0/18 table 100 <br />ip rule add to 202.99.64.0/19 table 100 <br />ip rule add to 202.99.96.0/21 table 100 <br />ip rule add to 202.99.104.0/21 table 100 <br />ip rule add to 202.99.112.0/20 table 100 <br />ip rule add to 202.99.128.0/19 table 100 <br />ip rule add to 202.99.160.0/21 table 100 <br />ip rule add to 202.99.168.0/21 table 100 <br />ip rule add to 202.99.176.0/20 table 100 <br />ip rule add to 202.99.192.0/21 table 100 <br />ip rule add to 202.99.200.0/21 table 100 <br />ip rule add to 202.99.208.0/20 table 100 <br />ip rule add to 202.99.224.0/21 table 100 <br />ip rule add to 202.99.232.0/21 table 100 <br />ip rule add to 202.99.240.0/20 table 100 <br />ip rule add to 202.102.128.0/21 table 100 <br />ip rule add to 202.102.136.0/21 table 100 <br />ip rule add to 202.102.144.0/20 table 100 <br />ip rule add to 202.102.160.0/19 table 100 <br />ip rule add to 202.102.224.0/21 table 100 <br />ip rule add to 202.102.232.0/21 table 100 <br />ip rule add to 202.102.240.0/20 table 100 <br />ip rule add to 202.106.0.0/16 table 100 <br />ip rule add to 202.107.0.0/17 table 100 <br />ip rule add to 202.108.0.0/16 table 100 <br />ip rule add to 202.110.0.0/18 table 100 <br />ip rule add to 202.110.64.0/18 table 100 <br />ip rule add to 202.110.192.0/18 table 100 <br />ip rule add to 202.111.128.0/19 table 100 <br />ip rule add to 202.111.160.0/19 table 100 <br />ip rule add to 203.93.8.0/24 table 100 <br />ip rule add to 203.93.9.0/24 table 100 <br />ip rule add to 203.93.10.0/23 table 100 <br />ip rule add to 203.93.12.0/22 table 100 <br />ip rule add to 203.93.16.0/20 table 100 <br />ip rule add to 203.93.32.0/19 table 100 <br />ip rule add to 203.93.64.0/18 table 100 <br />ip rule add to 203.93.128.0/21 table 100 <br />ip rule add to 203.93.136.0/22 table 100 <br />ip rule add to 203.93.140.0/24 table 100 <br />ip rule add to 203.93.141.0/24 table 100 <br />ip rule add to 203.93.142.0/23 table 100 <br />ip rule add to 203.93.144.0/20 table 100 <br />ip rule add to 203.93.160.0/19 table 100 <br />ip rule add to 203.93.192.0/18 table 100 <br />ip rule add to 203.175.192.0/18 table 100 <br />ip rule add to 210.13.128.0/17 table 100 <br />ip rule add to 210.14.160.0/19 table 100 <br />ip rule add to 210.14.192.0/19 table 100 <br />ip rule add to 210.14.224.0/19 table 100 <br />ip rule add to 210.15.32.0/19 table 100 <br />ip rule add to 210.15.64.0/19 table 100 <br />ip rule add to 210.15.96.0/19 table 100 <br />ip rule add to 210.15.128.0/18 table 100 <br />ip rule add to 210.21.0.0/17 table 100 <br />ip rule add to 210.21.128.0/17 table 100 <br />ip rule add to 210.22.0.0/16 table 100 <br />ip rule add to 210.51.0.0/16 table 100 <br />ip rule add to 210.52.0.0/18 table 100 <br />ip rule add to 210.52.64.0/18 table 100 <br />ip rule add to 210.52.128.0/17 table 100 <br />ip rule add to 210.53.0.0/17 table 100 <br />ip rule add to 210.53.128.0/17 table 100 <br />ip rule add to 210.74.96.0/19 table 100 <br />ip rule add to 210.74.128.0/19 table 100 <br />ip rule add to 210.78.0.0/19 table 100 <br />ip rule add to 210.82.0.0/15 table 100 <br />ip rule add to 211.144.0.0/15 table 100 <br />ip rule add to 218.7.0.0/16 table 100 <br />ip rule add to 218.8.0.0/15 table 100 <br />ip rule add to 218.10.0.0/16 table 100 <br />ip rule add to 218.11.0.0/16 table 100 <br />ip rule add to 218.12.0.0/16 table 100 <br />ip rule add to 218.21.128.0/17 table 100 <br />ip rule add to 218.24.0.0/15 table 100 <br />ip rule add to 218.26.0.0/16 table 100 <br />ip rule add to 218.27.0.0/16 table 100 <br />ip rule add to 218.28.0.0/15 table 100 <br />ip rule add to 218.56.0.0/14 table 100 <br />ip rule add to 218.60.0.0/15 table 100 <br />ip rule add to 218.62.0.0/17 table 100 <br />ip rule add to 218.67.128.0/17 table 100 <br />ip rule add to 218.68.0.0/15 table 100 <br />ip rule add to 218.104.0.0/17 table 100 <br />ip rule add to 218.104.128.0/19 table 100 <br />ip rule add to 218.104.160.0/19 table 100 <br />ip rule add to 218.104.192.0/21 table 100 <br />ip rule add to 218.104.200.0/21 table 100 <br />ip rule add to 218.104.208.0/20 table 100 <br />ip rule add to 218.104.224.0/19 table 100 <br />ip rule add to 218.105.0.0/16 table 100 <br />ip rule add to 218.106.0.0/15 table 100 <br />ip rule add to 219.154.0.0/15 table 100 <br />ip rule add to 219.156.0.0/15 table 100 <br />ip rule add to 219.158.0.0/17 table 100 <br />ip rule add to 219.158.128.0/17 table 100 <br />ip rule add to 219.159.0.0/18 table 100 <br />ip rule add to 219.232.0.0/14 table 100 <br />ip rule add to 220.248.0.0/14 table 100 <br />ip rule add to 220.252.0.0/16 table 100 <br />ip rule add to 221.0.0.0/15 table 100 <br />ip rule add to 221.2.0.0/16 table 100 <br />ip rule add to 221.3.0.0/17 table 100 <br />ip rule add to 221.3.128.0/17 table 100 <br />ip rule add to 221.4.0.0/16 table 100 <br />ip rule add to 221.5.0.0/17 table 100 <br />ip rule add to 221.5.128.0/17 table 100 <br />ip rule add to 221.6.0.0/16 table 100 <br />ip rule add to 221.7.0.0/19 table 100 <br />ip rule add to 221.7.32.0/19 table 100 <br />ip rule add to 221.7.64.0/19 table 100 <br />ip rule add to 221.7.96.0/19 table 100 <br />ip rule add to 221.7.128.0/17 table 100 <br />ip rule add to 221.8.0.0/15 table 100 <br />ip rule add to 221.10.0.0/16 table 100 <br />ip rule add to 221.11.0.0/17 table 100 <br />ip rule add to 221.11.128.0/18 table 100 <br />ip rule add to 221.11.192.0/19 table 100 <br />ip rule add to 221.11.224.0/19 table 100 <br />ip rule add to 221.12.0.0/17 table 100 <br />ip rule add to 221.12.128.0/18 table 100 <br />ip rule add to 221.13.0.0/18 table 100 <br />ip rule add to 221.13.64.0/19 table 100 <br />ip rule add to 221.13.96.0/19 table 100 <br />ip rule add to 221.13.128.0/17 table 100 <br />ip rule add to 221.14.0.0/15 table 100 <br />ip rule add to 221.136.0.0/16 table 100 <br />ip rule add to 221.192.0.0/15 table 100 <br />ip rule add to 221.194.0.0/16 table 100 <br />ip rule add to 221.195.0.0/16 table 100 <br />ip rule add to 221.196.0.0/15 table 100 <br />ip rule add to 221.198.0.0/16 table 100 <br />ip rule add to 221.199.0.0/19 table 100 <br />ip rule add to 221.199.32.0/20 table 100 <br />ip rule add to 221.199.48.0/20 table 100 <br />ip rule add to 221.199.64.0/18 table 100 <br />ip rule add to 221.199.128.0/18 table 100 <br />ip rule add to 221.199.192.0/20 table 100 <br />ip rule add to 221.199.224.0/19 table 100 <br />ip rule add to 221.200.0.0/14 table 100 <br />ip rule add to 221.204.0.0/15 table 100 <br />ip rule add to 221.206.0.0/16 table 100 <br />ip rule add to 221.207.0.0/18 table 100 <br />ip rule add to 221.207.64.0/18 table 100 <br />ip rule add to 221.207.128.0/17 table 100 <br />ip rule add to 221.208.0.0/14 table 100 <br />ip rule add to 221.212.0.0/16 table 100 <br />ip rule add to 221.213.0.0/16 table 100 <br />ip rule add to 221.214.0.0/15 table 100 <br />ip rule add to 221.216.0.0/13 table 100 <br />ip rule add to 222.128.0.0/14 table 100 <br />ip rule add to 222.132.0.0/14 table 100 <br />ip rule add to 222.136.0.0/13 table 100 <br />ip rule add to 222.160.0.0/15 table 100 <br />ip rule add to 222.162.0.0/16 table 100 <br />ip rule add to 222.163.0.0/19 table 100 <br />ip rule add to 222.163.32.0/19 table 100 <br />ip rule add to 222.163.64.0/18 table 100 <br />ip rule add to 222.163.128.0/17 table 100 </p>
<p>8.&nbsp;&nbsp;&nbsp; arp绑定.建立/etc/ethers文件,具体格式如: </p>
<p>192.168.2.102&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00:11:5B:1D9:77 <br />192.168.2.111&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00:11:5B:1A2:6C </p>
<p>9.&nbsp;&nbsp;&nbsp; 用TC进行流量控制,HTB具体分三类.具体脚本如下:&nbsp; (#脚本文件位置/etc/tc) <br />#/bin/bash <br />tc qdisc del dev eth1 root 2&gt;/dev/null <br />tc qdisc del dev eth1 ingress 2&gt;/dev/null <br />tc qdisc del dev eth0 root 2&gt;/dev/null <br />tc qdisc del dev eth0 ingress 2&gt;/dev/null <br />tc qdisc del dev eth2 root 2&gt;/dev/null <br />tc qdisc del dev eth2 ingress 2&gt;/dev/null <br />tc qdisc add dev eth1 root handle 1: htb default 15 <br />tc qdisc add dev eth2 root handle 2: htb default 15 <br />tc qdisc add dev eth0 root handle 3: htb default 15 <br />tc class add dev eth1 parent 1:&nbsp; classid 1:1&nbsp; htb rate 75Mbit ceil 75Mbit <br />tc class add dev eth2 parent 2:&nbsp; classid 2:1&nbsp; htb rate 75Mbit ceil 75Mbit <br />tc class add dev eth0 parent 3:&nbsp; classid 3:1&nbsp; htb rate 85Mbit ceil 85Mbit <br />tc class add dev eth1 parent 1:1 classid 1:11 htb rate 30Mbit ceil 30Mbit prio 0 <br />tc class add dev eth2 parent 2:1 classid 2:11 htb rate 30Mbit ceil 30Mbit prio 0 <br />tc class add dev eth0 parent 3:1 classid 3:11 htb rate 40Mbit ceil 40Mbit prio 0 <br />tc class add dev eth1 parent 1:1 classid 1:12 htb rate 25Mbit ceil 25Mbit prio 1 <br />tc class add dev eth2 parent 2:1 classid 2:12 htb rate 25Mbit ceil 25Mbit prio 1 <br />tc class add dev eth0 parent 3:1 classid 3:12 htb rate 25Mbit ceil 25Mbit prio 1 <br />tc class add dev eth1 parent 1:1 classid 1:15 htb rate 20Mbit ceil 20Mbit prio 2 <br />tc class add dev eth2 parent 2:1 classid 2:15 htb rate 20Mbit ceil 20Mbit prio 2 <br />tc class add dev eth0 parent 3:1 classid 3:15 htb rate 20Mbit ceil 20Mbit prio 2 <br />tc qdisc add dev eth1 parent 1:12 handle 12: sfq <br />tc qdisc add dev eth1 parent 1:15 handle 15: sfq <br />tc qdisc add dev eth2 parent 2:12 handle 12: sfq <br />tc qdisc add dev eth2 parent 2:15 handle 15: sfq <br />tc qdisc add dev eth0 parent 3:12 handle 12: sfq <br />tc qdisc add dev eth0 parent 3:15 handle 15: sfq <br />tc filter add dev eth1 parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11 <br />tc filter add dev eth2 parent 2:0 protocol ip prio 1 handle 1 fw classid 2:11 <br />tc filter add dev eth0 parent 3:0 protocol ip prio 1 handle 1 fw classid 3:11 <br />tc filter add dev eth1 parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12 <br />tc filter add dev eth2 parent 2:0 protocol ip prio 2 handle 2 fw classid 2:12 <br />tc filter add dev eth0 parent 3:0 protocol ip prio 2 handle 2 fw classid 3:12 <br />tc filter add dev eth1 parent 1:0 protocol ip prio 5 handle 5 fw classid 1:15 <br />tc filter add dev eth2 parent 2:0 protocol ip prio 5 handle 5 fw classid 2:15 <br />tc filter add dev eth0 parent 3:0 protocol ip prio 5 handle 5 fw classid 3:15 <br />tc qdisc add dev eth1 handle ffff: ingress <br />tc qdisc add dev eth2 handle ffff: ingress <br />tc filter add dev eth1 parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate 85Mbit burst 15k drop flowid :1 <br />tc filter add dev eth2 parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate 85Mbit burst 15k drop flowid :1 <br />iptables -F -t mangle <br />iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j RETURN <br />iptables -t mangle -I PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x1 <br />iptables -t mangle -I PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j RETURN <br />iptables -t mangle -A PREROUTING -p icmp -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -p icmp -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 22 -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 22 -j RETURN <br />iptables -t mangle -A PREROUTING -p udp -m udp --dport 53 -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -p udp -m udp --dport 53 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m multiport --port 6299,39311,10001,13000,29000,6299,28088,7000,7100,30810,6020,40041,54321,5858 -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -p tcp -m multiport --port 6299,39311,10001,13000,29000,6299,28088,7000,7100,30810,6020,40041,54321,5858 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m length --length :500 -j MARK --set-mark 0x1 <br />iptables -t mangle -A PREROUTING -p tcp -m length --length :500 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j MARK --set-mark 0x2 <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 80 -j MARK --set-mark 0x2 <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 80 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 443 -j MARK --set-mark 0x2 <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 443 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 443 -j MARK --set-mark 0x2 <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 443 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 8080 -j MARK --set-mark 0x2&nbsp;&nbsp; <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 8080 -j RETURN <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 8080 -j MARK --set-mark 0x2&nbsp;&nbsp; <br />iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 8080 -j RETURN <br />iptables -t mangle -A PREROUTING -j MARK --set-mark 0x5 </p>
<p>10.&nbsp; 防火墙脚本如下(存放位置:/etc/fire) </p>
<p>#/bin/sh <br />/sbin/modprobe ip_tables <br />/sbin/modprobe ip_nat_ftp <br />/sbin/modprobe ip_conntrack_ftp </p>
<p>iptables -F <br />iptables -t nat -F <br />iptables -X <br />iptables -t nat -X </p>
<p>iptables -P INPUT Drop <br />iptables -P FORWARD ACCEPT <br />iptables -P OUTPUT ACCEPT </p>
<p>#Allow SSH connection <br />iptables -A INPUT -i lo -j ACCEPT <br />iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT <br />iptables -A INPUT -p tcp --dport 22 -j ACCEPT </p>
<p>#IGMP <br />iptables -A INPUT -p ICMP -d 218.28.1.0/24 -m limit --limit 1/s --limit-burst 10 -j ACCEPT <br />iptables -A INPUT -p ICMP -d 222.88.1.0/24 -m limit --limit 1/s --limit-burst 10 -j ACCEPT <br />iptables -A INPUT -p ICMP -d 192.168.0.0/22 -m limit --limit 1/s --limit-burst 10 -j ACCEPT <br />iptables -A INPUT -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT </p>
<p>#synfoold </p>
<p>iptables -N synfoold <br />iptables -A synfoold -p tcp --syn -m limit --limit 1/s -j RETURN <br />iptables -A synfoold -p tcp -j REJECT --reject-with tcp-reset <br />iptables -A INPUT -p tcp -m state --state NEW -j synfoold </p>
<p>iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT <br />iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT <br />iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT <br />iptables -N syn-flood <br />iptables -A INPUT -p tcp --syn -j syn-flood <br />iptables -I syn-flood -p tcp -m limit --limit 3/s --limit-burst 6 -j RETURN <br />iptables -A syn-flood -j REJECT </p>
<p>#NAT <br />iptables -t nat -A POSTROUTING -s 192.168.0.0/22 -o eth1 -j MASQUERADE <br />iptables -t nat -A POSTROUTING -s 192.168.0.0/22 -o eth2 -j MASQUERADE </p>
<p>11. 最后rc.local脚本如下: <br />#!/bin/sh <br />touch /var/lock/subsys/local <br />echo &quot;1&quot; &gt; /proc/sys/net/ipv4/ip_forward <br />echo &quot;65535&quot; &gt; /proc/sys/net/ipv4/ip_conntrack_max <br />/etc/cncroute <br />/etc/fire <br />arp -f <br />/etc/tc <br />#注:5 ,6 ,7 三步合并为/etc/cncroute 脚本</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>网上参考资料2:</strong></p>
<p><strong></strong></p>
<p><u><font color="#800080">网络环境</font></u></p>
<p><u><font color="#800080">服务器(网关)：<br />&nbsp;&nbsp; eth0 为LAN口，IP为 LAN_IP = 192.168.0.1 <br />&nbsp;&nbsp; eth1 为第一个WAN口，接电信线路，IP为 CTC_IP，网关为 CTC_GW<br />&nbsp;&nbsp; eth2 为第二个WAN口，接网通线路，IP为 CNC_IP，网关为 CNC_GW</font></u></p>
<p><u><font color="#800080">内网网站<br />&nbsp;&nbsp; HTTP_SERVER = 192.168.0.100&nbsp;<br />&nbsp;&nbsp;&nbsp; </font></u></p>
<p><u><font color="#800080">内核打补丁</font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp; 如果你希望外网用户，不管通过哪个IP都可以访问到服务器或映射后的内网服务器，那么你就需要为内核打上补丁，<br />&nbsp;&nbsp; 补丁在 <a href="http://www.ssi.bg/~ja/#routes">http://www.ssi.bg/~ja/#routes</a> 可以下载到，在 Static, Alternative Routes, Dead Gateway Detection, NAT 找和内核对应的 patch</font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp; 下载后为内核打上，然后在 </font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp;&nbsp; Networking&nbsp; ---&gt;&nbsp; Networking options&nbsp; ---&gt;&nbsp; IP: advanced router </font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp;&nbsp; 把 IP: equal cost multipath with caching support (EXPERIMENTAL) 前面的勾去掉</font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp;&nbsp; 如果你不想打补丁，或不想动内核，有个简单的办法来实现，即写一个脚本，每隔2秒钟刷新一次route cache</font></u></p>
<p><u><font color="#800080">&nbsp;&nbsp;&nbsp; while : ; do<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ip route flush cache<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep 2<br />&nbsp;&nbsp;&nbsp; done</font></u></p>
<u><font color="#800080">
<p><br />双线策略的实现</p>
<p>1. 静态路由方式（这种方式是最简单的）</p>
<p>&nbsp;&nbsp;&nbsp; 1) 设置默认路由，比如电信<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ip route replace default via 电信网关 dev eth1</p>
<p>&nbsp;&nbsp;&nbsp; 2) 设置策略路由，对另外一条线路</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ip route add 网通路由表1 via 网通网关 dev eth2 metric 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ip route add 网通路由表2 via 网通网关 dev eth2 metric 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .... </p>
<p>&nbsp;&nbsp;&nbsp; 3) 添加原路返回路由 </p>
<p>&nbsp;&nbsp;&nbsp; 策略路由规则设置完后，还要为每条线路加入相应的 &ldquo;原路返回路由&rdquo;（从哪条线进来的数据，最终还是从这条线出去），不然就会出现这样的问题：<br />&nbsp;&nbsp;&nbsp; 电信用户通过网通的IP访问不到服务器，网通用户也不能通过电信IP访问到服务器</p>
<p>&nbsp;&nbsp;&nbsp; ip route flush table 100<br />&nbsp;&nbsp;&nbsp; ip route add default via 电信网关 dev eth1 src 电信IP table 100 prio 50<br />&nbsp;&nbsp;&nbsp; ip rule add from 电信IP table 100</p>
<p>&nbsp;&nbsp;&nbsp; ip route flush table 200<br />&nbsp;&nbsp;&nbsp; ip route add default via 网通网关 dev eth2 src 网通IP table 200 prio 50<br />&nbsp;&nbsp;&nbsp; ip rule add from 网通IP table 200</p>
<p>&nbsp;&nbsp;&nbsp; 出来加入本身的原路返回路由之外，还应加入局域网接口的，不然通过端口映射后，内网无法通过外网IP访问到映射后的服务器<br />&nbsp;&nbsp;&nbsp; ip route add 192.168.0.0/24 dev eth0&nbsp; scope link&nbsp; src 192.168.0.1 table 100<br />&nbsp;&nbsp;&nbsp; ip route add 192.168.0.0/24 dev eth0&nbsp; scope link&nbsp; src 192.168.0.1 table 200</p>
<p><br />2. 策略路由方式</p>
<p>&nbsp;&nbsp;&nbsp; 为了方便，我们增加2个策略路由表，电信 =&gt; 100，网通 =&gt; 200，这样再添加规则时，就可以直接用自定义的名称来替代数字</p>
<p>&nbsp;&nbsp;&nbsp; echo &quot;100 ctc&quot;　&gt;&gt;&nbsp; /etc/iproute2/rt_tables<br />&nbsp;&nbsp;&nbsp; echo &quot;200 cnc&quot;&nbsp; &gt;&gt;　/etc/iproute2/rt_tables</p>
<p>&nbsp;&nbsp;&nbsp; 1）设置默认路由（电信）<br />&nbsp;&nbsp;&nbsp; ip route replace default via 电信网关 dev eth1</p>
<p>&nbsp;&nbsp;&nbsp; 2）对网通进行基于目的地址的策略路由<br />&nbsp;&nbsp;&nbsp; ip rule add to 网通路由表1 table cnc prio 100<br />&nbsp;&nbsp;&nbsp; ip rule add to 网通路由表2 table cnc prio 100<br />&nbsp;&nbsp;&nbsp; .... </p>
<p>&nbsp;&nbsp;&nbsp; 3）添加原路返回路由</p>
<p>&nbsp;&nbsp;&nbsp; ip route flush table ctc<br />&nbsp;&nbsp;&nbsp; ip route add default via 电信网关 dev eth1 src 电信IP table ctc<br />&nbsp;&nbsp;&nbsp; ip route add 192.168.0.0/24 dev eth0&nbsp; scope link&nbsp; src 192.168.0.1 table ctc<br />&nbsp;&nbsp;&nbsp; ip rule add from 电信IP table ctc</p>
<p>&nbsp;&nbsp;&nbsp; ip route flush table cnc<br />&nbsp;&nbsp;&nbsp; ip route add default via 网通网关 dev eth2 src 网通IP table cnc<br />&nbsp;&nbsp;&nbsp; ip route add 192.168.0.0/24 dev eth0&nbsp; scope link&nbsp; src 192.168.0.1 table ctc<br />&nbsp;&nbsp;&nbsp; ip rule add from 网通IP table cnc</p>
<p>3. iptables打标记＋iproute2 fwmark</p>
<p>&nbsp;&nbsp;&nbsp; 1）使用 CONNMARK 对连接进行标记</p>
<p>&nbsp;&nbsp;&nbsp; 外网进来数据<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A PREROUTING -i eth1 -m conntrack&nbsp; --ctstate NEW&nbsp; -j CONNMARK --set-mark 0x100<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A PREROUTING -i eth2 -m conntrack&nbsp; --ctstate NEW&nbsp; -j CONNMARK --set-mark 0x200</p>
<p>&nbsp;&nbsp;&nbsp; 转发出去的数据<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A POSTROUTING -o eth1&nbsp; -m conntrack&nbsp; --ctstate NEW&nbsp; -j CONNMARK --set-mark 0x100<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A POSTROUTING -o eth2&nbsp; -m conntrack&nbsp; --ctstate NEW&nbsp; -j CONNMARK --set-mark 0x200</p>
<p>&nbsp;&nbsp;&nbsp; 局域网进来数据<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A PREROUTING -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark</p>
<p>&nbsp;&nbsp;&nbsp; 本地出去数据<br />&nbsp;&nbsp;&nbsp; iptables -t mangle -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark</p>
<p>&nbsp;&nbsp; 2）在 IPROUTE2 中做基于 fwmark 的策略路由</p>
<p>&nbsp;&nbsp; ip rule add fwmark 0x100 table ctc prio 40<br />&nbsp;&nbsp; ip rule add fwmark 0x200 table cnc prio 40</p>
<p>&nbsp;&nbsp; 3）添加原路返回路由</p>
<p>&nbsp;&nbsp; ip route add table ctc to $CTC_NET dev eth1&nbsp; scope link<br />&nbsp;&nbsp; ip route add table ctc to $CNC_NET dev eth2&nbsp; scope link<br />&nbsp;&nbsp; ip route add table ctc to 192.168.0.0/24 dev eth0&nbsp; scope link<br />&nbsp;&nbsp; ip route add default via 电信网关 dev eth1 table ctc</p>
<p>&nbsp;&nbsp; ip route add table cnc to $CTC_NET dev eth1 scope link<br />&nbsp;&nbsp; ip route add table cnc to $CNC_NET dev eth2&nbsp; scope link<br />&nbsp;&nbsp; ip route add table cnc to 192.168.0.0/24 dev eth0&nbsp; scope link<br />&nbsp;&nbsp; ip route add default via 网通网关 dev eth2 table cnc </p>
<p><br />Iptables/NAT 规则</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; /sbin/iptables -t nat -A POSTROUTING -o eth1 -s 局域网网段 -j SNAT --to-source 电信外网IP<br />&nbsp;&nbsp;&nbsp;&nbsp; /sbin/iptables -t nat -A POSTROUTING -o eth2 -s 局域网网段 -j SNAT --to-source 网通外网IP</p>
<p>&nbsp;&nbsp;&nbsp; 如果外网IP是动态的，可以用 MASQUERADE </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; /sbin/iptables -t nat -A POSTROUTING -o eth1 -s 局域网网段 -j MASQUERADE<br />&nbsp;&nbsp;&nbsp;&nbsp; /sbin/iptables -t nat -A POSTROUTING -o eth2 -s 局域网网段 -j MASQUERADE</p>
<p><br />端口映射</p>
<p>&nbsp;&nbsp;&nbsp; 端口映射可以分别针对两条线做端口映射<br />&nbsp;&nbsp;&nbsp; 比如 LAN口的IP为 192.168.0.1，内网服务器IP为 192.168.0.100，映射端口为 80</p>
<p>&nbsp;&nbsp;&nbsp; iptables -t nat -A PREROUTING -p tcp --dport 80 -d 电信IP -j DNAT --to-destination 192.168.0.100<br />&nbsp;&nbsp;&nbsp; iptables -t nat -A PREROUTING -p tcp --dport 80 -d 网通IP -j DNAT --to-destination 192.168.0.100</p>
<p>&nbsp;&nbsp;&nbsp; 端口回流（内网可以通过外网IP访问映射后的服务器）<br />&nbsp;&nbsp;&nbsp; iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.0/24 --dport 80 -d 192.168.0.100 -j SNAT --to-source 192.168.0.1</p>
<p>&nbsp;&nbsp;&nbsp; [注]：上述规则应放到 NAT 规则之前</p>
<p><br />常见问题（FAQ）</p>
<p>1. 不能实现 &ldquo;交叉访问&rdquo; 到服务器</p>
<p>&nbsp;&nbsp;&nbsp; 即：会出现外网电信用户只能通过电信IP访问到服务器，而通过网通IP访问不了；<br />&nbsp;&nbsp;&nbsp; 同理，网通用户只能通过网通IP访问到服务器，而通过电信IP却访问不了。也就是只是单纯地解决了 &ldquo;内网访问哪里，走哪条线路&rdquo; </p>
<p>答：电信用户通过网通IP访问时，数据到达了服务器上，本应该从网通的线路返回的，但最终却从电信的线路出去了，这样的数据会被上层网关丢弃。</p>
<p>&nbsp;&nbsp;&nbsp; 此时需要加入 &ldquo;原路返回路由&rdquo; ，实现 &ldquo;从哪条线来的，依然从哪条线返回&ldquo;。</p>
<p><br />2. 外网用户不能交叉访问映射后的内网服务器</p>
<p>&nbsp;&nbsp;&nbsp; 即：电信用户可以通过电信IP访问到内网服务器，网通用户可以通过网通IP访问到内网服务器<br />&nbsp;&nbsp;&nbsp; 但是：网通用户不能通过电信IP访问到内网服务器，电信用户也不能网通IP访问到内网服务器</p>
<p>答：路由缓存引起的，给内核打补丁，或每隔 2 秒左右刷新路由缓存</p>
<p><br />3. 内网用户不能通过外网IP访问内网服务器</p>
<p>答：a. 没有做SNAT（端口回流），加入回流规则即可<br />&nbsp;&nbsp;&nbsp;&nbsp; b. 加入 &rdquo;原路返回路由&ldquo; 时，没有将局域网的路由加入进去</p>
<p><br />深入探讨</p>
<p>1. 上述三种方式哪一种效率最高? 如何来评估 ?</p>
<p>2. 双线失效保护，即掉线自动切换的实现（定时探测每条线路的连通性）<br />&nbsp;&nbsp;&nbsp; 可参考 <a href="http://linux.chinaunix.net/bbs/v">http://linux.chinaunix.net/bbs/v</a> ... p;highlight=coolend</p>
<p>3. 通过VPN方式实现虚拟双线，即传说中的&ldquo;借线&rdquo;</p>
<p>4. 内网访问指定外网IP时走指定线路，指定内网IP上网走指定线路</p>
<p>&nbsp; <br />转自: <a href="http://linux.chinaunix.net/bbs/thread-1018118-1-1.html">http://linux.chinaunix.net/bbs/thread-1018118-1-1.html</a> <br />&nbsp; <br />&nbsp; <br />################################################################## <br />&nbsp; </p>
<p>昨天仔细测试了一下~~~ 发现有点问题</p>
<p>外网用户访问映射后的内网服务器，只能通过1个IP访问，但是过7－8分钟后，却可以用另外一个IP访问，但是原来的那个IP就访问不了</p>
<p>比如：服务器的电信IP： 222.x, 网通IP: 218.x ，80端口映射到了内网的 192.168.0.100 网站服务器上</p>
<p>电信用户可以通过 222.x 访问到网站，但通过 222.x 访问不了 ；过几分钟后，可以通过 218.x 访问，但是此时通过 222.x 又访问不了，也就是说同一时间只能通过一个IP访问到。</p>
<p>添加的防火墙规则如下：</p>
<p>iptables -t mangle -I PREROUTING -i eth1 -d 电信IP -m conntrack --ctstate NEW -j CONNMARK --set-mark 100</p>
<p>iptables -t mangle -I PREROUTING -i eth2 -d 网通IP -m conntrack --ctstate NEW -j CONNMARK --set-mark 200</p>
<p>iptables -t mangle -I PREROUTING -i eth0 --sport 80 -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark</p>
<p>不知哪里有问题，请高人出来指点下~~~ 谢谢！ <br />&nbsp; <br />#### <br />&nbsp; <br />通过网通IP访问时，不能通过电信IP访问，但是在服务器上运行 ip route flush cache 后，可以通过电信IP访问了，但是通过网通IP又不能访问了，再运行下 ip route flush cache，又可以通过网通I访问了，但又不能通过电信IP访问，真是怪事~~~ </p>
<p>如果写一个脚本每隔一秒钟不停地&nbsp; ip route flush cache，似乎可以解决问题，但是这样也太BT了点，还是希望能找到问题根本所在</p>
<p>#### <br />&nbsp; <br />你需要给kernel打个补丁，然后在kernel中disable route cache</p>
<p>在这儿:http://www.ssi.bg/~ja/#routes</p>
<p>在这个子项中&quot;Static, Alternative Routes, Dead Gateway Detection, NAT&quot;找相应的patch <br />&nbsp; <br />#### <br />&nbsp; </p>
<p>哈哈～～～ 成功了！果然把内核中那个 route cache 一去掉，不用频繁 flush cache ，外网就可以用2个IP同时访问服务器。<br />文章出处：<a href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008727/134085.html">http://www.diybl.com/course/6_system/linux/Linuxjs/2008727/134085.html</a><a href="http://blog.csdn.net/enchen/archive/2009/03/15/3991758.aspx"></a></p>
</font></u>]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=43</link>
			<title><![CDATA[VNC使用]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Sat,30 May 2009 23:55:41 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=43</guid>	
		<description><![CDATA[两种VNC服务器软件：vnc4server和vncserver，客户端使用ultravnc，当然也可以使用tightvnc等其他的VNC客户端软件。<br/><br/>VNC4Server篇<br/>服务器：<br/>vnc4server-免费软件，可以从源里面找到。<br/>sudo apt-get install vnc4server<br/><br/><br/>客户端：<br/>UltraVNC for Windows<br/>也是一个免费软件。UltraVNC包含Server和Client，不过我只安装了Client.<br/>特别值得一提的是，这个软件的插件里面有一个DSMplugin，可以实现加密传输，非常的好。<br/>UltraVNC下载：<br/><a href="http://ultravnc.sourceforge.net/" target="_blank">http://ultravnc.sourceforge.net/</a><br/><br/>DSMPlugin下载（这里用不上了）：<br/><a href="http://msrc4plugin.home.comcast.net/~msrc4plugin/index.html" target="_blank">http://msrc4plugin.home.comcast.net/~msrc4plugin/index.html</a><br/><br/>配置：<br/>1、生成一个passwd文件<br/>vnc4passwd<br/><br/>在$HOME/.vnc目录下面生成一个passwd文件。<br/>$HOME/.vnc是一个vnc4server的关键目录。<br/><br/>2、开启vnc4server<br/><br/>输入：vnc4server<br/>会得到：desktop的名称，这个名称在客户端连接的时候用到。如果是desktop:1,在客户端连接的时候就填写：ip:5901，依此类推，如果是Desktop 2，在客户端的时候填写：ip:5902....<br/>首次运行会提示生成了.vnc/xstartup文件，这个文件里面包含着登录启动X时的一下配置。<br/><br/>特别注意：<br/>现在从UltraVNC登录，可能得到一个比较简单的窗口，因为VNC4Server缺省启动的WM是twm，如果希望启动gnome，需要改动.vnc/xstartup ,我的配置如下：<br/><br/>#!/bin/sh<br/><br/># Uncomment the following two lines for normal desktop:<br/># unset SESSION_MANAGER<br/># exec /etc/X11/xinit/xinitrc<br/><br/>[ -x /etc/vnc/xstartup ] &amp;&amp; exec /etc/vnc/xstartup<br/>[ -r $HOME/.Xresources ] &amp;&amp; xrdb $HOME/.Xresources<br/>xsetroot -solid grey<br/>vncconfig -iconic &amp;<br/>xterm -geometry 1024x768+10+10 -ls -title &#34;$VNCDESKTOP Desktop&#34; &amp;<br/>gnome-session &amp;<br/><br/>这样登录的时候，会自动启动gnome<br/>如果实在不是非常明白原理，或者出现问题，可以查看/usr/bin/vnc4server文件，这是一个Perl文件，你将非常明白其中的运作原理。<br/><br/>VNCServer篇：<br/>如果使用vncserver，那么缺省的配置文件在$HOME/.vncrc里面，vncserver系统全局的配置文件在/etc/vnc.conf里面，从/usr/bin/vncserver（也是一个Perl文件）可以看到它的运作原理。<br/>另外，还需要改动/etc/vnc.conf，因为vncserver默认使用的是xfree系统，需要修改一下配置文件，大体如下：<br/><br/>$XFConfigPath = &#34;/etc/X11/xorg.conf&#34;;<br/><br/>当然在这里还可以看到其他变量，如vncStartup，如果想启动默认的X系统，可以配置如下：<br/>$vncStartup = &#34;/etc/X11/Xsession&#34;;<br/><br/>如果在$HOME/.vncrc里面进行如下配置：<br/><br/>#配置X系统为xorg<br/>$XFconfigPath = &#34;/etc/X11/xorg.conf&#34;;<br/><br/># 启动默认Xsession<br/>$vncStartup = &#34;/etc/X11/Xsession&#34;;<br/><br/>#分辨率<br/>$geometry =&#34;800x600&#34;;<br/><br/>登录以后，会自动到默认桌面，如Gnome等，如果Ubuntu本机登录一样。<br/><br/>另外还看到用xinited和vncserver来实现后台服务，不过我觉得风险还是比较大，因为它缺省使用root来运行，需要谨慎。<br/><br/>Linux的VNC充分理由了Xorg的C/S体系，非常好用啊！]]></description>
		</item>
		
			<item>
			<link>http://www.idcnote.com/default.asp?id=37</link>
			<title><![CDATA[在redhat AS4中架反向代理服务器squid]]></title>
			<author>wentaiyou@126.com(kevin)</author>
			<category><![CDATA[GNU/Linux]]></category>
			<pubDate>Sun,01 Feb 2009 09:45:32 +0800</pubDate>
			<guid>http://www.idcnote.com/default.asp?id=37</guid>	
		<description><![CDATA[<p>安装SQUID非常简单.</p>
<p>1. rpm -ivh <a href="http://soft.idcnote.com/linux/socks/squid-2.5.STABLE6-3.i386.rpm">squid-2.5.STABLE6-3.i386.rpm</a>&nbsp; 这个包在AS光盘中就有.</p>
<p>2. vi /etc/squid/squid.conf&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; 在这个文件上面添加以下内容<br />&nbsp;&nbsp;&nbsp;&nbsp; httpd_accel_host virtual<br />&nbsp;&nbsp;&nbsp;&nbsp; httpd_accel_port 80&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //代理80端口,一般WEB服务器用的就是这个端口<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;httpd_accel_with_proxy on<br />&nbsp;&nbsp; &nbsp; httpd_accel_uses_host_header on<br />&nbsp;&nbsp; &nbsp; acl all src 0.0.0.0/0.0.0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //允许所有IP<br />&nbsp; &nbsp;&nbsp; http_access allow all<br /></p>
<p>3. vi /etc/sysctl.conf <br />&nbsp;&nbsp;&nbsp; net.ipv4.ip_forward = 1</p>
<p>4.设置防火墙的转发包<br />&nbsp;iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128&nbsp;&nbsp; //SQUID用的是3128端口<br />&nbsp;service iptables save<br />&nbsp;iptables-save &gt; /etc/sysconfig/iptables<br />这里的意思是.设置NAT转发,把您的ETH0端口上的所有接到的访问80口的包转到本机3128端口来处理.如果您不只一个网卡口.这里就要跟据您WEB实际所在IP在哪个网卡上来写.</p>
<p>5. vi /etc/hosts<br />&nbsp; IP&nbsp;&nbsp; URL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IP为实际WEB的URL所在的IP,</p>
<p>6.service squid start</p>
<p>以上只是对SQUID做最简单的配置.让代理工作起来.更多的优化还没学习.有空深入了解一下.这个可是好东西.+上智能DNS他就是一个简单.CDN.</p>]]></description>
		</item>
		
</channel>
</rss>