iT邦幫忙

0

Linux 鎖了上網80 port,如何開放一組目的地ip出去!

請問各位高手 小弟我剛接手的Linux CentOS-5.3 有用proxy 限制上網鎖80 port, 但公司新系統需要傳簡訊驗證
碼出去(簡訊驗證碼走的也是80 port),我要怎麼開放針對 簡訊公司(目的地)的ip 都出的去.
以下是公司的 proxy 設定 ,
設定檔內容:
acl all src 0.0.0.0/0.0.0.0
acl all_pass_ip src "/etc/squid/setting/all_pass_ip"
acl callcenter_leader_ip src "/etc/squid/setting/squid.superallow.hosts"
acl basic_user_ip src "/etc/squid/setting/squid.allow.hosts"
acl yushun_ip src "/etc/squid/setting/yushun_user_ip"

acl denytimes time "/etc/squid/squid.deny.times"
acl morning time 9:30-12:00
acl afternoon time 14:00-18:00

acl allurl dstdomain "/etc/squid/squid.allurl"
acl whilefile urlpath_regex -i "/etc/squid/squid.allow.whilefile"
acl whileurl dstdomain "/etc/squid/squid.allow.whileurl"
acl blockfile urlpath_regex -i "/etc/squid/squid.deny.blockfile"
acl superblockurl dstdomain "/etc/squid/squid.superdeny.blockurl"
acl blockurl dstdomain "/etc/squid/squid.deny.blockurl"
acl yushunurl dstdomain "/etc/squid/setting/squid.yushundeny.blockurl"
acl lanurl dstdomain "/etc/squid/setting/lanurl

acl localhost src 127.0.0.1/255.255.255.255

acl Safe_ports port 80 # http
acl SSL_ports port 443
#acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
################################################################
http_access allow localhost

http_access allow all_pass_ip
http_access allow basic_user_ip lanurl
http_access deny yushunurl
http_access allow yushun_ip
http_access deny superblockurl
http_access allow callcenter_leader_ip

http_access allow whilefile
http_access allow whileurl
http_access deny denytimes
http_access deny blockfile
http_access deny blockurl

http_access allow basic_user_ip

http_access deny all
感謝各位高手看完. 有人能幫我解答嗎? 謝謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
6
逮丸逮丸
iT邦大師 1 級 ‧ 2010-09-20 14:10:53
最佳解答

silly 的思考方向對,
但細節要再確認一下。
參閱一下鳥哥的:
代理伺服器 squid 設定 裡的 acl 的用法與用途

<pre class="c" name="code">acl whileurl dstdomain "/etc/squid/squid.allow.whileurl"
acl lanurl dstdomain "/etc/squid/setting/lanurl"

這兩個 dstdomain 應該是以 domain 的方式為目的,
用 IP 寫在其中可能不大能有所作用,而需用在 dst 裡。

所以解決方法有二:
1.加在現有樣式比對的條件裡:

<pre class="c" name="code">acl whilefile urlpath_regex -i "/etc/squid/squid.allow.whilefile"

其中的語法加上這一條件:

<pre class="c" name="code">^http://210\.68\.77\.234.*

2.新增有關目的端以IP用的 dst 的目的列表,
假設新增:

<pre class="c" name="code">acl whitedst dst "/etc/squid/squid.allow.whitedst"
# 其內容為
210.68.77.234/32

並在 http_access allow whileurl 的下面多加一行:

<pre class="c" name="code">http_access allow whitedst

就可把有關IP的目標列表設該檔案,也應會生效。

10
silly
iT邦好手 2 級 ‧ 2010-09-20 12:30:13

squid.allow.whileurl 或
/etc/squid/setting/lanurl
加入目的位置(10.68.77.234)後重新讀取設定應該就可以了。

會有錯誤有可能是你加入的資訊格式不正確。( <-- 沒看到錯誤訊息瞎猜的 )

6
jackwan
iT邦研究生 4 級 ‧ 2010-09-20 16:02:44

既然知道ip,建議直接由防火牆放,不需走Proxy.

看更多先前的回應...收起先前的回應...
chang0206 iT邦新手 1 級 ‧ 2010-09-21 09:27:18 檢舉

+1
我也覺得用FW去控制會比較方便。
如果真要用proxy去控制,那就針對這組IP做一個ACL吧.
注意一下ACL套用順序就可以了.

f7112345 iT邦新手 5 級 ‧ 2010-09-21 09:57:01 檢舉

高手們 我防火牆 已經新增一條
#iptables -A OUTPUT -o eth0 -d 210.68.77.234 -j ACCEPT
但開了還是不行. 我proxy有限制她們上網,只開防火牆可以嗎? 還是我防火牆 還需要開其他地方. 謝謝.

f7112345 iT邦新手 5 級 ‧ 2010-09-21 10:01:57 檢舉

重啟後的錯誤訊息. 有人能幫我解答嗎?
[root@localhost setting]# service squid restart
正在停止 squid: 2010/09/15 14:25:51| WARNING: '210.68.77.234' is a subnetwork of '210.68.77.234'
2010/09/15 14:25:51| WARNING: because of this '210.68.77.234' is ignored to keep splay tree searching predictable
2010/09/15 14:25:51| WARNING: You should probably remove '210.68.77.234' from the ACL named 'basic_user_ip'
2010/09/15 14:25:51| aclParseIpData: WARNING: Netmask masks away part of the specified IP in '210.68.77.234/24'
2010/09/15 14:25:51| WARNING: '210.68.77.234' is a subnetwork of '210.68.77.0/255.255.255.0'
2010/09/15 14:25:51| WARNING: because of this '210.68.77.0/255.255.255.0' is ignored to keep splay tree searching predictable
2010/09/15 14:25:51| WARNING: You should probably remove '210.68.77.234' from the ACL named 'basic_user_ip'
................ [ 確定 ]
正在啟動 squid: . [ 確定 ]
我後來進'basic_user_ip'把裡面的內容全刪.重啟還是出現一樣的訊息.

您不應把 210.68.77.234 設在 basic_user_ip,
設在那檔案裡,等於是讓 210.68.77.234 可以用您們的 proxy。

sharbui iT邦新手 3 級 ‧ 2010-09-21 14:00:57 檢舉

鎖port 80 .是指把埠80轉到squid port上.然後再去做限制嗎?
那表示你應該是在nat PREROUTING chain下的條件吧...
那你怎會在output 增設條件呢?..
要讓210.68.77.234的封包不轉到proxy.就應該讓他的rule在轉埠的rule之前.

sharbui iT邦新手 3 級 ‧ 2010-09-21 14:03:53 檢舉

那些squid的錯誤訊息應該只是有ACL物件重複設定了IP或網段而已.再查查你的ACL相關物件的設定吧
'210.68.77.0/255.255.255.0' <==有重複指定或寫了2次

jackwan iT邦研究生 4 級 ‧ 2010-11-26 09:34:45 檢舉

iptables -t nat -A POSTROUTING -d 210.68.77.234/255.255.255.255 -j MASQUERADE

我要發表回答

立即登入回答