• <output id="aynwq"><form id="aynwq"><code id="aynwq"></code></form></output>

    <mark id="aynwq"><option id="aynwq"></option></mark>
  • <mark id="aynwq"><option id="aynwq"></option></mark><label id="aynwq"><dl id="aynwq"></dl></label>
  • 學習啦 > 學習電腦 > 操作系統 > Linux教程 > Linux怎樣設置透明代理

    Linux怎樣設置透明代理

    時間: 春健736 分享

    Linux怎樣設置透明代理

      透明模式的特點就是對用戶是透明的(Transparent),即用戶意識不到防火墻的存在。那么Linux怎樣設置透明代理?今天學習啦小編與大家分享下Linux設置透明代理的具體操作步驟,有需要的朋友不妨了解下。

      Linux設置透明代理方法

      1.什么是透明代理?

      如果你問:我如何才能使得用戶的瀏覽器不需要任何代理設置就能使用我的Squid cache代理服務器上網?此時你就需要使用透明代理。透明代理讓你的客戶端不需設置任何代理,當包經過透時代理服務器時實際上被重定向到squid代理服務器的代理端口(如8080),即由本地代理服務器向外請求所需數據然后拷貝給客戶端。

      2.我需要什么樣的環境才能實現透明代理?

      a.客戶端的windows PC的網關必須設成Squid代理服務器,因為既然你的browser中沒有任何代理設置,你要訪問某個站點時,包必須經經過squid代理服務器才能被重定向,故這是最基本的條件。

      b.客戶端必須正確設置DNS服務器。因為既然現在不用設置任何代理。則DNS必須由browser來解析,也就是要由客戶端的PC中TCP/IP中設置的DNS服務器來正確解析出某個站點的IP地址來。

      c.服務器端可以安裝squid代理服務器,1.x or 2.x版本均可。

      3.配置Squid代理,啟動透明代理功能

      Squid-2

      加下面的行到你的/etc/squid/squid.conf中

      http_port 8080

      httpd_accel_host virtual

      httpd_accel_port 80

      httpd_accel_with_proxy on

      httpd_accel_uses_host_header on

      Squid-1.1

      加下面的行到/etc/squid.conf

      http_port 8080

      httpd_accel virtual 80

      httpd_accel_with_proxy on

      httpd_accel_uses_host_header on

      4. 重啟動squid. 用下面的命令:

      #/usr/sbin/squid -k reconfigure

      如提示內核不支持透明代理。則你需要重新編譯內核,enable 透明代理的支持。

      下面是你需要啟動的內核項目:

      [*] Network firewalls

      [ ] Socket Filtering

      [*] Unix domain sockets

      [*] TCP/IP networking

      [ ] IP: multicasting

      [ ] IP: advanced router

      [ ] IP: kernel level autoconfiguration

      [*] IP: firewalling

      [ ] IP: firewall packet netlink device

      [*] IP: always defragment (required for masquerading)

      [*] IP: transparent proxy support

      5. 下面的命令針對Linux 2.2.x內核:

      # Accept all on lookback

      /sbin/ipchains -A input -j ACCEPT -i lo

      #Accept my own IP, to prevent loops (repeat for each interface/alias)

      /sbin/ipchains -A input -j ACCEPT -p tcp -d 192.168.11.1/32 80

      #Send all traffic destined to port 80 to Squid on port 80

      /sbin/ipchains -A input -j REDIRECT 8080 -p tcp -s 192.168.11.0/24 -d 0/0 80

      下面的命令針對Linux 2.0.x內核:

      # Accept all on loopback

      ipfwadm -I -a accept -W lo

      # Accept my own IP, to prevent loops (repeat for each interface/alias)

      ipfwadm -I -a accept -P tcp -D 192.168.11.1/32 80

      # Send all traffic destined to port 80 to Squid on port 3128

      ipfwadm -I -a accept -P tcp -S 192.168.11.0/24 -D 0/0 80 -r 8080

      6.應注意的問題:

      a. 這種透明代理只能針對http協議,不能針對FTP協議

      b. PC的默認網關應設成squid 代理服務器

      c. 防火墻重定向規則在其它的input規則的前面,注意順序。

      如:

      /etc/rc.d/rc.firewall:

      #!/bin/sh

      # rc.firewall Linux kernel firewalling rules

      FW=/sbin/ipfwadm

      # Flush rules, for testing purposes

      for i in I O F # A # If we enabled accounting too

      do

      ${FW} -$i -f

      done

      # Default policies:

      ${FW} -I -p rej # Incoming policy: reject (quick error)

      ${FW} -O -p acc # Output policy: accept

      ${FW} -F -p den # Forwarding policy: deny

      # Input Rules:

      # Loopback-interface (local access, eg, to local nameserver):

      ${FW} -I -a acc -S localhost/32 -D localhost/32

      # Local Ethernet-interface:

      # Redirect to Squid proxy server:

      ${FW} -I -a acc -P tcp -D default/0 80 -r 8080

      # Accept packets from local network:

      ${FW} -I -a acc -P all -S localnet/8 -D default/0 -W eth0

      # Only required for other types of traffic (FTP, Telnet):

      # Forward localnet with masquerading (udp and tcp, no icmp!):

      ${FW} -F -a m -P tcp -S localnet/8 -D default/0

      ${FW} -F -a m -P udp -S localnet/8 -D default/0

      Here all traffic from the local LAN with any destination gets redirected to the

      local port 8080. Rules can be viewed like this:

      IP firewall input rules, default policy: reject

      type prot source destination ports

      acc all 127.0.0.1 127.0.0.1 n/a

      acc/r tcp 10.0.0.0/8 0.0.0.0/0 * -> 80 => 8080

      acc all 10.0.0.0/8 0.0.0.0/0 n/a

      acc tcp 0.0.0.0/0 0.0.0.0/0 * -> *

    看過“Linux怎樣設置透明代理”的人還看了:

    1.linux下free命令使用方法

    2.Linux下nl命令怎么用

    3.Linux命令如何連接

    4.Linux下traceroute命令怎么用

    5.mv命令怎么用

    6.11個很有用的Linux 命令

    892508 主站蜘蛛池模板: 国产视频www| 欧美日韩国产码高清综合人成| 天天做天天爱天天干| 亚洲综合综合在线| 97精品伊人久久久大香线蕉 | 亚洲AV无码专区亚洲AV不卡| 性无码专区无码| 第一福利官方航导航| 爱情岛讨论坛线路亚洲高品质| 在线免费观看视频你懂的| 亚洲人成在线免费观看| 韩国三级在线视频| 新婚熄与翁公老张林莹莹| 免费a级毛片永久免费| 777久久精品一区二区三区无码| 最近的中文字幕视频完整| 国产专区中文字幕| www.夜夜操.com| 欧美人妻精品一区二区三区| 天天躁日日躁狠狠躁人妻| 亚洲精品无码mv在线观看| 亚洲色图欧美在线| 挺进邻居丰满少妇的身体| 亚洲综合15p| 黄页网址大全免费观看12网站| 手机在线看片国产| 亚洲欧美自拍另类图片色| 欧美色图一区二区| 成人免费一区二区三区在线观看| 亚洲福利一区二区精品秒拍| 黄色永久免费网站| 樱花草在线社区www| а√天堂中文最新版地址bt| 久久久久久亚洲精品| 亚洲熟女乱色一区二区三区| 国产v精品成人免费视频400条| 亚洲国产欧美视频| 色妞www精品视频观看软件| 夜夜燥天天燥2022| 久久婷婷香蕉热狠狠综合| 精品久久久久久成人AV|