全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2371
推到 Plurk!
推到 Facebook!

BSD 應用:Load Balancing

 
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-01 10:57:08 IP:61.221.xxx.xxx 未訂閱
http://free.tnc.edu.tw/modules/newbb/viewtopic.php?topic_id=253&forum=9#forumpost846    
應用:Load Balancing
小弟參考這裡的範例
http://www.openbsd.org/faq/pf/pools.html
把兩條對外的線路做 load balancing
但有一些問題,小弟不知道如何解決,找了不少文章了,不知道是不是我方法或是方向不對,請先進們指點迷津。
1.對外的其中一條線斷了,內部的電腦,就無法連線出去
2.內部電腦無法使用 ftp    我的pf.conf設定如下:    # /etc/pf.conf 
ext_if0="vr0" # external 0
ext_if1="vr1" # external 1
int_if="sis0" # internal network.
internal_net="192.168.1.1/24"
external0_addr="192.192.30.5"
external1_addr="192.192.35.21"
ext_gw0="192.192.30.1"
ext_gw1="192.192.35.1"    scrub in all    nat on $ext_if0 from $internal_net to any -> ($ext_if0)
nat on $ext_if1 from $internal_net to any -> ($ext_if1)    # pass all outgoing packets on internal interface
pass out on $int_if from any to $internal_net
# pass in quick any packets destined for the gateway itself
pass in quick on $int_if from $internal_net to $int_if
# load balance outgoing tcp traffic from internal network.
pass in on $int_if route-to { ($ext_if0 $ext_gw0), ($ext_if1 $ext_gw1) } round-robin proto tcp from $internal_net to any flags S/SA modulate state
# load balance outgoing udp and icmp traffic from internal network
pass in on $int_if route-to { ($ext_if0 $ext_gw0), ($ext_if1 $ext_gw1) } round-robin proto { udp, icmp } from $internal_net to any keep state    # general "pass out" rules for external interfaces
pass out on $ext_if0 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if0 proto { udp, icmp } from any to any keep state
pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if1 proto { udp, icmp } from any to any keep state    # route packets from any IPs on $ext_if0 to $ext_gw0 and the same for
# $ext_if1 and $ext_gw1
pass out on $ext_if0 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any
pass out on $ext_if1 route-to ($ext_if0 $ext_gw0) from $ext_if0 to any    ----------------
By TERN && Cheng-Yu Lin
 
Re: 應用:Load Balancing 請在nat下面加上 rdr on {$ext_if0,$ext_if1} proto tcp from $internal_net to any port 21 -> 127.0.0.1 port 8021 記得把inetd.conf 的ftp-proxy那一行前面的#去掉後再重啟inetd 詳情請看拙作:網路設定 會斷線的問題是因為pf以循環(round-robin)的方式作load balancing但是它不會去偵測是不是斷線,所以網路會受影響。目前還沒有看到有什麼方式可以解決的,有人是另外再寫程式去做動態路由,但是我不太欣賞這種作法(其實是找不到啦,有找到的話我還是會作)。聽說ghost大大先前有看過討論pf load balancing的文章,不知道是否還在呢。是不是能請大大有空的話放上來給大家研究研究?
Re: 應用:Load Balancing 引文: syfeng 寫道: 目前還沒有看到有什麼方式可以解決的,有人是另外再寫程式去做動態路由,但是我不太欣賞這種作法(其實是找不到啦,有找到的話我還是會作)。聽說ghost大大先前有看過討論pf load balancing的文章,不知道是否還在呢。是不是能請大大有空的話放上來給大家研究研究? 這篇貼出來了以後,我就應該還清欠債了吧? ---- BSD 全國 BBS 連線板 2001 年七月 標題:有這種東西嘛?隨機路由選擇? a:例如 server 有四條線路對外 ... 當封包由電腦往外送時,每一個封包都隨機選取一條路由 不管是否該線不通,反正等重送時又會再隨機選一條送出去 FreeBSD 能做到這樣嘛? b.非不能也,乃不為也。Sending packets with randomly chosen path is likely to cause out-of-order delivery of packets. That is bad for TCP a:那 ... 要是硬要強制這樣做呢?該怎麼做? 有什麼東西可以做的到? c:一個簡便的方法就是去改ipip tunnel這個device driver 利用routing的方式先將要出去的packet繞到改過的ipip這個device driver 然後這個改過的ipip tunnel device driver再決定要送到那一個網路卡去 但是誠如freedom所述,TCP packet out-or-ordering會造成TCP Retransmission的 問題.效能會打折扣. d:這個不是主要的問題吧!! out of order 本來就是 TCP 所要應付的問題之一, 只要各個 path 的 delay 不要差太多就不是問題, 或者是把 window 加大. 主要是你的 routing 會變的比較不穩定, 容式 packet lost, 不容易 debug. 另外就是 routing protocol 的問題, 目前 GLOBAL 使用 BGP4, 你的 ISP 接受你的 routing 嗎? 基本上 32個c 以下, ISP 是不會接受你的 peering 要求的, 這也是 apnic 要求的下限. b:TCP 的確可以處理 out-of-oder delivery, 可是也不是原來的 Jon Postel 的 RFC 937 就有的,而是後來 Van Jocabson 加的。而且, 就算不同 route 時間不大 1. 會有 overhead, tcp 可能送不快 2. receiver advised window 長不大, tcp 送不快 如果時間差大一點,可能 3. sender 可能常常會啟動 fast retransmission, 可是事實上 之前的 packet 並沒有丟,tcp 送不快 4. 因為 3. tcp 可能會多送出一堆沒有必要的 data, 造成 網路的負擔變重, 然後 out-of-order delivery 的機會又增加。 out-of-order delivery 的成因與影響可以參考 Vern Paxson 的博士論文。 *請支持並參與 Freenix 伺服文件撰寫驗證計畫 http://www.freenix-server.info 得即高歌失即休 任多悲愁也悠悠 青松影裡朦朧睡 燕飛無樓月已鉤 風起雲湧 II - 幽靈
Re: 應用:Load Balancing 試試看這個 # /etc/pf.conf ext_if0="vr0" # external 0 ext_if1="vr1" # external 1 int_if="sis0" # internal network. internal_net="192.168.1.1/24" external0_addr="192.192.30.5" external1_addr="192.192.35.21" ext_gw0="192.192.30.1" ext_gw1="192.192.35.1" set timeout src.track 60 scrub in all nat on $ext_if0 from $internal_net to any -> ($ext_if0) nat on $ext_if1 from $internal_net to any -> ($ext_if1) block all # pass all outgoing packets on internal interface pass out on $int_if from any to $internal_net # pass in quick any packets destined for the gateway itself pass in quick on $int_if from $internal_net to $int_if # load balance outgoing tcp traffic from internal network. pass in on $int_if route-to { ($ext_if0 $ext_gw0), ($ext_if1 $ext_gw1) } round-robin sticky-address proto tcp from $internal_net to any flags S/SA modulate state # load balance outgoing udp and icmp traffic from internal network pass in on $int_if route-to { ($ext_if0 $ext_gw0), ($ext_if1 $ext_gw1) } round-robin sticky-address proto { udp, icmp } from $internal_net to any keep state # general "pass out" rules for external interfaces pass out on $ext_if0 proto tcp from any to any flags S/SA modulate state pass out on $ext_if0 proto { udp, icmp } from any to any keep state pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state pass out on $ext_if1 proto { udp, icmp } from any to any keep state # route packets from any IPs on $ext_if0 to $ext_gw0 and the same for # $ext_if1 and $ext_gw1 pass out on $ext_if0 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any pass out on $ext_if1 route-to ($ext_if0 $ext_gw0) from $ext_if0 to any # eof 不過這個要安裝snapshots版的才行哦
系統時間:2024-05-16 18:18:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!