乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Squid+iptables的透明代理配置 - CIN的日志 - 網(wǎng)易博客

       jan_hf 2009-11-02

      Squid+iptables的透明代理配置

      默認(rèn)分類(lèi)   2008-02-24 01:37   閱讀57   評(píng)論0  
      字號(hào):    

      Squid+iptables的透明代理配置

      Firer2000

      2003-06-27

      硬件環(huán)境:兼容機(jī) 雙網(wǎng)卡

      軟件環(huán)境:linux7.1+squid-2.3.STABLE4-src.tar

      一.squid的安裝配置

      1.下載squid

      可以從squid主站下載:http://www.

      2.編譯安裝squid

      第一步:[root@www root]#tar xzvf squid-2.3.STABLE4-src.tar.gz

      第二步:[root@www root]#cd squid-2.3.STABLE4

      第三步:[root@www squid-2.3.STABLE4]#./configure --prefix=/usr/localsquid enable-ipf-transparent

      /*指定squid的安裝目錄和啟用透明代理*/

      第四步:[root@www squid-2.3.STABLE4]#make all

      第五步:[root@www squid-2.3.STABLE4]#make install

      以上五步執(zhí)行完畢,squid整個(gè)程序就會(huì)被安裝在/usr/local/squid目錄下.接下來(lái)再執(zhí)行以下幾步:

      第六步:進(jìn)入目錄/usr/local,以root身份執(zhí)行下面的命令,創(chuàng)建cache目錄和改變整個(gè)squid目錄的所有者為

      nobody.nobody:

      [root@www squid-2.3.STABLE4]#cd /usr/local/squid

      [root@www squid]# mkdir cache

      [root@www squid]# cd ..

      [root@www local]# chown nobody.nobody -R squid

      第七步:改變用戶(hù)為nobody,進(jìn)入/usr/local/squid/bin目錄,執(zhí)行./squid -z創(chuàng)建cache交換目錄

      [root@www local]# su nobody

      [root@www local]$cd /usr/local/squid/bin

      [root@www local]$./squid -z

      第八步:修改squid.conf文件,確保以下配置:

      httpd_accel_host virtual(記得把一句加上,我用的這個(gè)squid版本沒(méi)有這一句)

      httpd_accel_port 80

      httpd_accel_with_proxy on

      httpd_accel_uses_host_header on

      cache_effective_user nobody

      cache_effective_group nobody

      http_access allow all

      cache_dir ufs /usr/local/squid/cache 100 16 256

      ...

      最后啟動(dòng)squid:

      [root@www local]#/usr/local/squid/bin/squid

      查看進(jìn)程列表:

      [root@www local]#px ax

      應(yīng)該出現(xiàn)如下幾個(gè)進(jìn)程:

      ......... usr/local/squid

      ......... squid

      ......... unlink

      并且系統(tǒng)中應(yīng)該有如端口被監(jiān)聽(tīng):

      tcp 0 0 0.0.0.0:3128 0.0.0.0:* LISTEN

      udp 0 0 0.0.0.0:3130 0.0.0.0:*

      這些說(shuō)明squid正常啟動(dòng)了.

      ###如果squid不能正常工作,可能是域名的設(shè)置問(wèn)題,需要設(shè)置域名。

      讓系統(tǒng)啟動(dòng)時(shí)自動(dòng)運(yùn)行squid

      編輯/ect/rc.d/local文件,在末尾加上:

      su nobody -c "/usr/local/squid/bin/squid"

      ------------------------------------------------------------------------------------------------

      OK,通過(guò)以上設(shè)置我們就以就squid代理上網(wǎng)了.

      可以在ie瀏覽器中設(shè)置使用代理服務(wù)器,添入192.168.0.101:3128就可以上網(wǎng)了.

      但這一步還沒(méi)有實(shí)現(xiàn)透明代理,接下來(lái)我們開(kāi)始設(shè)置iptables

      二.設(shè)置iptables

      1、 首先使用linuxconf工具將enable routing 項(xiàng)打開(kāi)。在configure linuxconf modules 里選擇firewall的項(xiàng)。

      2、 #setup

      進(jìn)入services 去掉ipchains。

      3、在/etc/rc.d/目錄下用touch命令建立firewall文件,執(zhí)行chmod u+x firewall以改變文件屬性,編輯

      /etc/rc.d/rc.local文件,在末尾加上/etc/rc.d/firewall以確保開(kāi)機(jī)時(shí)能自動(dòng)運(yùn)行該腳本.

      firewall內(nèi)容為:

      modprobe ip_tables

      modprobe ip_nat_ftp

      modprobe ip_conntrack

      modprobe ip_conntrack_ftp

      echo 1>/proc/sys/net/ipv4/ip_forward

      iptables -t nat -A PREROUTING -i eht1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

      iptables -t nat -A POSTROUTING -s 172.16.0.0/23 -o eth0 -j SNAT --to 211.141.67.10

      ##############################################################################

      下面是原文給出的firewall腳本,共參考

      #!/bin/sh

      echo "Enable IP Forwarding..."

      echo "1">/proc/sys/net/ipv4/ip_forward

      echo "Starting iptables rules..."

      /sbin/modprobe iptable_filter

      /sbin/modprobe ip_tables

      /sbin/modprobe iptable_nat

      #Refresh all chains

      /sbin/iptables -F -t nat

      iptables -P INPUT DROP

      iptables -P FORWARD DROP

      iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

      iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to a.b.c.d

      iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

      #######################################################################################

      其中,eth1是內(nèi)部網(wǎng)卡,eth0是外部網(wǎng)卡。

      內(nèi)網(wǎng)ip地址為172.16.0.0/23

      eth0對(duì)應(yīng)的ip地址為:211.141.67.10

      結(jié)束.

      然后設(shè)置網(wǎng)關(guān)和dns后就可上網(wǎng)了.

      如需要還可以添加一些防火墻以增強(qiáng)安全性,具體參考本站:

      http://www./engineer/bye2000/doc/iptables1.htm

      http://www./engineer/bye2000/doc/iptables2.htm

      三:設(shè)置squid支持用戶(hù)認(rèn)證:

      說(shuō)明:透明代理和用戶(hù)認(rèn)證功能不能同時(shí)應(yīng)用。否則用戶(hù)認(rèn)證功能不起作用。

      假定squid source目錄在/tmp/ squid-2.3.STABLE4

      2. # cd /tmp/ squid-2.3.STABLE4/auth_modules/NCSA

      # make ncsa_auth

      3. 拷貝生成的執(zhí)行文件ncsa_auth到squid執(zhí)行文件目錄

      # cp ncsa_auth /usr/local/squid/bin

      4. 從Apache軟件包中得到程序htpasswd

      假設(shè)apache軟件安裝在/var/www目錄下

      #cd /usr/www/bin

      5.用htpasswd生成供Squid利用的用戶(hù)名和密碼認(rèn)證數(shù)據(jù)庫(kù)文件

      生成的密碼文件放在/usr/local/squid/etc 下。

      [root@mail bin]# ./htpasswd -c /usr/local/squid/etc/passwd test

      New password:

      Re-type new password:

      Adding password for user test

      這時(shí)在/usr/local/squid下就生成了passwd文件,并且加入了用戶(hù)test。

      6. 加其它更多的用戶(hù)

      #htpasswd /usr/loal/squid/etc/passwd newuser

      7. 修改squid.conf,enable ncsa_auth用戶(hù)認(rèn)證功能

      [root@linux etc]# more squid.conf | grep ncsa_auth

      authenticate_program /usr/local/squid/bin/ncsa_auth /usr/local/squid/etc/passwd

      8.修改ACL部分,象下面這樣:

      定義相關(guān)的用戶(hù)類(lèi)

      acl auth_user proxy_auth REQUIRED

      注意,REQUIRED關(guān)鍵字指明了接收所有合法用戶(hù)的訪問(wèn)。

      7.設(shè)置http_access

      http_access allow auth_user

      注意,如果你在改行中指定了多個(gè)允許訪問(wèn)的用戶(hù)類(lèi)的話,應(yīng)該把要認(rèn)證的用戶(hù)類(lèi)放在第一個(gè)。如下所示:

      錯(cuò)誤的配置:http_access allow auth_user all manager

      正確的配置:http_access allow auth_user manager all

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多