• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 回復-置頂: linux+squid+iptables企業方案征集

    發表于:2007-05-25來源:作者:點擊數: 標簽:
    申明,本人腳本禁止轉載,請尊重本人勞動成果: 試試: 首先本人認為01是不可能實現的,而11我又不會 SQL 和SAMBA認證只會基本認證,除此之外其余均能實現 假設子網192.168.1.0/24,某個域名為www.163.com通過PING的其IP為202.108.36.196,通過其IP限制收發該

    申明,本人腳本禁止轉載,請尊重本人勞動成果:
    試試:
    首先本人認為01 是不可能實現的,而11我又不會SQL和SAMBA認證只會基本認證,除此之外其余均能實現
    假設子網192.168.1.0/24,某個域名為www.163.com通過PING 的其IP為202.108.36.196,通過其IP限制收發該域名郵件(可在iptables中實現)
    外網網卡為eth0內網網卡為eht1,為eth1綁定192.168.1.201和192.168.0.201
    cp eth1 eth1:1
    修改eht1:1
    沒有限制的用戶為192.168.0.201以后的IP用MAC標志
    由于AS3沒有安裝GCC而本身的SQUID里又沒有NCSA文件,固重新安裝GCC和SQUID,
    tar zxvf squid-2.5.STABLE7.tar.gz
    cd squid-2.5.STABLE7
    ./configure --prefix=/usr/local/squid
    --sysconfdir=/etc/squid                                   #配置文件位置
    --enable-arp-acl                                         #客戶端的MAC地址進行管理
    --enable-linux.netfilter                                  #允許使用Linux的透明功能
    --enable-pthreads 
    --enable-err-language="Simplify_Chinese"  
    --enable-default-err-language="Simplify_Chinese"
    #上面兩個選項告訴Squid編入并使用簡體中文錯誤信息
     --enable-storeio=ufs,null                                #可以不用緩沖
    --enable-auth="basic"                                 #認證方式
    --enable-baisc-auth-helpers="NCSA"                    #認證程序為
    --enable-underscore                                   #允許解析的URL中出現下劃線
    make
    make install
    開始配置squid.conf
    ##################################################################################################
    服務器配置
    icp_port 0
    cache_store_log none
    cache_aclearcase/" target="_blank" >ccess_log /dev/null   
    cache_log /dev/null           
    http_port 3128
    cache_mem 128 MB
    cache_dir null /tmp

    pid_filename none
    client_netmask 255.255.255.255
    half_closed_clients on

    #用戶分類                                         
    auth_param basic program /usr/bin/ncsa_auth /usr/etc/passwd
    auth_param basic children 5
    auth_param basic realm Tianfuming proxy-caching server
    auth_param basic credentialsttl 2 hours 
    acl normal proxy_auth REQUIDE              #用戶認證
    acl advance arp 00:01:02:1f:2c:3e 00:01:02:3c:1a:8b ...   #10 IP/MAC綁定用戶名認證上網;
    acl lana src 192.168.1.0/24
    acl lanb src 192.168.0.1-192.168.0.200/32

    #行為分類
    acl download urlpath_regex -i \.mp3$ \.exe$ \.avi$ \.rar$ \.rvmb$ \.jpg  #禁止下載
    #acl conncount maxconn 5               #最大連接數
    acl worktime MTWHF 8:00-18:00         # 04、允許全體人員在固定時間,有部分限制,
    #不在此時間之內,撤除限制(在http_access中限制)
    acl qq dstdomain .snnu.edu.cn
    acl badwords url_regex sex

    acl localhost src 127.0.0.1/32
    acl all src 0.0.0.0/0.0.0.0

    http_access allow advance                 # 03 允許部分人完全沒有限制;
    http_access allow localhost
    #http_access deny conncount normal
    http_access deny ! 
    http_access deny badwords worktime         # 不允許訪問特定url字符網站
    http_access deny qq worktime               # 06 不允許訪問特定的站點
    http_access allow lana                     # 02 允許部分人可以下載
    http_access deny download  worktime        # 05 不允許下載的特定url字符:exe/zip等等;
    http_access allowd lanb homepage           #08、允許部分人員只能瀏覽指定網站;
    http_access allow normal
    http_access deny all                      #除這些,禁止所有
    #結合透明代理   07、透明代理與用戶認證共存
    httpd_accel_host virtual
    httpd_accel_port 80
    httpd_accel_with_proxy on
    httpd_accel_uses_host_header on
    ####################################################################################
    iptables腳本
    ####################################################################################
    #! /bin/sh

    UPLINK="eth0"
    UPIP="a.b.c.d"
    LANLINK="eth1"
    ROUTER="yes"
    #NAT="UPIP/dynamic"
    NAT="UPIP"
    INTERFACES="lo eth0 eth1"
    SERVICES="80 22 25 110 "
    deny="" 
    case "$@" in
    start)
            echo -n "Starting firewall..."
            modprobe ip_nat_ftp 
    modprobe ip_conntrack_ftp 
    iptables -P INPUT DROP
            iptables -A INPUT -i ! ${UPLINK} -j  ACCEPT
            iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
            iptables -A FORWARD DROP
            iptables -A FORWARD -p tcp -m multiport --dport 25 80 110 -j ACCEPT
            iptables -A FORWARD -d !202.108.36.196 -p tcp -m multiport --dprot 25 110 -j DROP  ##09、只允許收發郵件(所有域名郵件
            iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT     #(smtp,pop3))和只能收某域名收發某域名郵件
    #iptables -P OUTPUT DROP
            #enable public access to certain services
            for x in ${SERVICES}
            do
                    iptables -A INPUT -p tcp --dport ${x} -m state --state NEW -j ACCEPT
            done

    for y in ${deny}
    do
    iptables -A OUTPUT -p tcp --dport ${y} -j DROP
    iptables -A OUTPUT -p udp --dport ${y} -j DROP
    done

    #enable system-log
    #iptables -A INPUT -j LOG --log-prefix "bad input:"

            iptables -A INPUT -p tcp -i ${UPLINK} -j REJECT --reject-with tcp-reset
            #iptables -A INPUT -p udp -i ${UPLINK} -j REJECT --reject-with icmp-port-unreachable

            #explicitly disable ECN
            if [ -e /proc/sys/net/ipv4/tcp_ecn ]
            then
                    echo 0 > /proc/sys/net/ipv4/tcp_ecn
            fi

            #disable spoofing on all interfaces
            for x in ${INTERFACES}
            do
                    echo 1 > /proc/sys/net/ipv4/conf/${x}/rp_filter
            done

            if [ "$ROUTER" = "yes" ]
            then
                    #we're a router of some kind, enable IP forwarding
                    echo 1 > /proc/sys/net/ipv4/ip_forward
                    if [ "$NAT" = "dynamic" ]
                    then
                            #dynamic IP address, use masquerading
                            iptables -t nat -A POSTROUTING -o ${UPLINK} -j MASQUERADE
                    elif [ "$NAT" != "" ]
                    then
                            #static IP, use SNAT
                            iptables -t nat -A PREROUTING -i ${LANLINK} -d ! ${UPIP} -j DNAT --to-ports 3128
                            iptables -t nat -A POSTROUTING -o ${UPLINK} -j SNAT --to ${UPIP}
                    fi
            fi
            echo "OK!"
            exit 0
    ;;
    stop)
            echo -n "Stopping firewall..."
            iptables -F INPUT
            iptables -P INPUT ACCEPT
            iptables -F OUTPUT
    iptables -P OUTPUT ACCEPT
    #turn off NAT/masquerading, if any
            #iptables -t nat -F POSTROUTING
            echo "OK!"
            exit 0
    ;;
    restart)
            $0 stop
            $0 start

    ;;
    show)
    clear
    echo ">-------------------------------------------------------------------"
    iptables -L
    echo ">-------------------------------------------------------------------"
    iptables -t nat -L POSTROUTING
    exit 0
    ;;
    *)
            echo "Usage: $0 {start|stop|restart|show}"
            exit 1
    esac

     段譽 回復于:2004-12-20 01:42:36
    多謝,并請大家測試。

    PS:可能不會搞代理了,但是希望能給大家提供交流的平臺。

     chris_wan 回復于:2004-12-22 19:19:51
    暈倒,這么好的東東竟然沒有人頂...........................

    樓主我幫你測試,有什么問題請教你.

    我的MSN: chris_wan@hotmail.com (24小時在線)

            QQ:278352648 (不是常在線)

     chris_wan 回復于:2004-12-22 19:22:57
    強列建議加精--置頂!

     sailboy 回復于:2004-12-24 19:00:05
    謝謝

     chris_wan 回復于:2004-12-28 16:59:55
    好象有點錯誤,請看

    [root@sztl-fw2 firewall]# ./firewall.sh 
    Usage: ./firewall.sh {start|stop|restart|show}
    [root@sztl-fw2 firewall]# ./firewall.sh start
    Starting firewall...Bad argument `DROP'
    Try `iptables -h' or 'iptables --help' for more information.
    Bad argument `80'
    Try `iptables -h' or 'iptables --help' for more information.
    iptables v1.2.8: Unknown arg `--dprot'
    Try `iptables -h' or 'iptables --help' for more information.
    iptables v1.2.8: Unknown arg `--to-ports'
    Try `iptables -h' or 'iptables --help' for more information.
    OK!
    [root@sztl-fw2 firewall]# iptables -L
    Chain INPUT (policy DROP)
    target     prot opt source               destination         
    ACCEPT     all  --  anywhere             anywhere           
    ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED 
    ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:http state NEW 
    ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:ssh state NEW 
    ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:smtp state NEW 
    ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:pop3 state NEW 
    REJECT     tcp  --  anywhere             anywhere           reject-with tcp-reset 

    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED 

    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    [root@sztl-fw2 firewall]# iptables -t nat -L
    Chain PREROUTING (policy ACCEPT)
    target     prot opt source               destination         

    Chain POSTROUTING (policy ACCEPT)
    target     prot opt source               destination         
    SNAT       all  --  anywhere             anywhere           to:192.168.9.1 

    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination

     chris_wan 回復于:2005-01-03 11:39:21
    嗯,怎么沒人回呢

     tianfuming 回復于:2005-01-04 12:09:24
    你把該腳本放到/sbin下然后chmod +x /sbin/firewall
    然后/sbin/firewall start試試

     Linux小魚兒 回復于:2005-01-14 15:11:06
    [code:1:a4eff34bb4]tianfuming
    你好,你在這里說到可以[/code:1:a4eff34bb4]
    [code:1:a4eff34bb4]重新安裝GCC[/code:1:a4eff34bb4]
    我想問一下是怎么個裝法,我沒有Rhat9 的光盤。

     sailboy 回復于:2005-01-18 16:44:24
    支持.!!!

     unixli 回復于:2005-03-02 11:27:16
    [quote:0d6724ff88="chris_wan"]l-fw2 firewall]# iptables -t nat -L
    Chain PREROUTING (policy ACCEPT)
    target     prot opt source               destination         

    Chain POSTROUTING (policy ACCEPT)
    target     prot opt source   ..........[/quote:0d6724ff88]

    iptables -A FORWARD -d !202.108.36.196 -p tcp -m multiport --[color=red:0d6724ff88]dprot[/color:0d6724ff88] 25 110 -j DROP

    這句有筆誤,dprot應改為dport

     lzlux 回復于:2005-03-26 16:55:37
    http_access allowd lanb homepage #08、允許部分人員只能瀏覽指定網站;

    ???
    有http_access allowd .... 這個命令參數嗎??

     zhangxiaosan 回復于:2005-03-28 11:43:15
    zhichi

     joyaid 回復于:2005-05-01 21:55:32
    up

     dqi 回復于:2005-05-08 22:30:02
    我用的代理服務器redhat linux 9.0 ADSL共享上網,客戶機WIN2000連接外部的VPN服務器連接不上,錯誤721。我的iptables設置的很簡單:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
    就那么多。那位大哥知道在加點iptables命令,我的VPN就可以連接上?

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>