歡迎您光臨本站 註冊首頁

iptables+squid的nat透明代理的qq語音

←手機掃碼閱讀     火星人 @ 2014-03-05 , reply:0

iptables+squid的nat透明代理的qq語音

麻煩你幫我看看這樣的配置能否達到qq語音聊天和文件傳輸嗎?

eth0 ip 192.168.0.1 mask 255.255.255.0

eht1 ip你外網的ip

gate你外網的gateip

rm /etc/squid/squid.conf

vi /etc/squid/squid.conf

http_port 3128

acl all src 192.168.0.0/24

http_access allow all

httpd_accel host virtual

httpd_accel_port 80

httpd_accel_with_proxy on

httpd_accel_user_host_header on

cache_mem 82 MB

cache_dir ufs /dev/shm 128 16 256

dns_nameservers xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx #你本地的dns伺服器ip

cache_swap_low 90

cache_swap_high 100

maximum_object_size 1024 KB

cache_access_log /dev/null

cache_log /var/log/squid/cache.log

cache_store_log none

unlinkd_program /usr/lib/squid/unlinkd

cache_effective_user squid

cache_effective_group squid

visible_hostname localhost

然後squid -Z看看有無錯誤

vi /bin/firewall

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

iptables -t nat -A PREROUTING -s 192.168.0.200/32 -p tcp --dport 80 -j REDIRECT 3128

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
《解決方案》

squid.conf應該沒什麼問題,你沒做任何限制
iptables試試以下腳本:

#! /bin/bash

for table in filter nat mangle
do
    iptables -F $table
    iptables -X $table
done

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -s 192.168.0.200/32 -p tcp --dport 80 -j REDIRECT 3128
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE

《解決方案》

那天,既然 INPUT 和 FORWARD 的默認規則都是 ACCPET,就沒必要再寫那兩個 state 的規則了
《解決方案》

也是,寫不寫都無所謂了。
我是從我的腳本上直接複製過來的,為了方便,把INPUT 和 FORWARD 都ACCEPT了。
《解決方案》

個人覺得,為了安全還是應該將默認規則置為 DROP 好些,最起碼 INPUT 就要用 DROP

[火星人 ] iptables+squid的nat透明代理的qq語音已經有186次圍觀

http://coctec.com/docs/service/show-post-38988.html