In many location, including but definitely not limited to India, single ADSL / Cable connections can be unreliable and also may not provide sufficient bandwidth for your purposes.在許多地點,包括但絕對不是僅限於印度,單一的ADSL /電纜連接,可以不可靠,也可能無法提供足夠的帶寬,為您的目的。 One way to increase reliability and bandwidth of your internet connection is to distribute the load (load balancing) using multiple connections.其中一個方法,以增加可靠性和帶寬,您的網際網路連線分配負荷(負載平衡)使用多個連接。 It is also imperative to have transparent fail-over so routes are automatically adjusted depending on the availability of the connections.它也必須有透明的故障這麼路線自動調整視可獲得的連線。 With load balancing and fail-over you can have reliable connectivity over two or more unreliable broadband connections (like BSNL or Tata Indicom in India).與負載平衡和故障排除,您可以有可靠的連接兩個或兩個以上不可靠的寬帶連接(如印度BSNL或Tata Indicom公司在印度) 。 I present you with the simplest solution to a complex problem with live examples.我提交您最簡單的解決方法,以一個複雜的問題,與活的例子。

Note: Load balancing doesn’t increase connection speed for a single connection.注:負載平衡不增加連線速度為一個單一的連接。 Its benefits are realized over multiple connections like in an office environment.它的好處是實現了多個連接一樣,在辦公室環境裡。 The benefits of fail-over are however realized even in a single user environment.好處不超過然而,實現了即使在一個單一的用戶環境。

The load balancing mechanism, to be discussed with example below, in Linux caches routes and doesn’t provide transparent fail-over support.負載平衡機制,以討論與下面的例子中,在Linux中暗藏的路線並沒有提供透明的故障排除的支持。 There are two solutions to incorporate transparent fail over - 1.有兩個解決方案,把透明的故障-1 。 compiling and using a custom Linux kernel with編制和使用自訂的Linux內核與 Julian Anastasov’s kernel patches朱利安anastasov的內核補丁 for dead gateway detection or 2.死網關檢測或2 。 user space script to monitor connections and dynamically change routing information.用戶空間腳本監察聯繫和動態變化的路由信息。

Julian Anastasov’s patches have two problems:朱利安anastasov的補丁有兩方面的問題:
1. 1 。 They work他們的工作 only when the first hop gateway is down只有當第一跳網關是下跌 . In many cases, including ours, the first hop gateway is the adsl modem cum router which is always up.在許多情況下,包括我國,第一跳網關是ADSL調製解調器暨路由器始終。 So we need a more robust solution for our purposes.因此,我們需要一個更強大的解決方案,我們的目的。

2. 2 。 You have to compile a custom kernel with patches.你要編譯一個自定義的內核與補丁。 This is somewhat complex procedure with reasonable chances of screwing up something.這是有點複雜的程序,以合理的機會,擰了一些。 It also forces you to re-patch the kernel every time you decide to update your kernel.它還勢力您重新修補程序的核心,每一次你決定要更新您的內核。 Overall I wouldn’t recommend anyone going for kernel patching route unless that is the only option.整體我不會推薦任何人去為內核補丁的路線,除非是唯一的選擇。 Also in that case you should look for a rpm based solution (like此外,在這種情況下你應該尋找一個每分鐘轉速為基礎的解決方案(如 livna rpm for nVidia drivers livna每分鐘轉速為NVIDIA驅動程序 ) which does it automatically for you. ) ,它並不,它會自動為您。

A better solution is to use a userspace program which monitors your connection and updates routes as necessary.一個更好的解決辦法是使用使用者計劃,監控您的連接和更新的路線,作為必要的。 I will provide a script which we use to constantly monitor our connections.我會提供一個腳本,我們使用的不斷監察我們的連接。 It provides transparent fail over support with two ADSL connections.它提供了透明,不超過支持兩個ADSL的連接。 It is fully configurable and can be used for any standard dual ADSL / Cable connections to provide transparent fail over support.這是完全可配置和可用於任何標準來衡量,雙重的ADSL /電纜連接,以提供透明的不能超過支持。 It can also be easily modified to use for more than two connections.它也可以很方便地進行修改,以使用兩個以上的連接。 You can also use it to log uptime / downtime of your connections您也可以用它來記錄的正常運行時間/停機時間您的連接 like we did像我們 .

Let’s first discuss load balancing with two ADSL / Cable connections and then we will see how to provide transparent fail-over support.讓我們先討論負載平衡與二的ADSL /電纜連接,然後我們將看到如何提供透明的故障排除的支持。 The ideas and script provided here can be easily used for more than two connections with minor modifications.想法和這裡提供的腳本可以很容易地用於兩個以上的連接與小的改動。

Requirements for Load Balancing multiple ADSL / Cable Connections要求負載平衡的多的ADSL /電纜連接

1. 1 。 Obviously you need to have multiple (A)DSL or Cable connections in the first place.顯然你需要有多個(一) DSL或電纜連接擺在首位。 Login as root for this job.以root登入,為這項工作。

2. 2 。 Find out the LAN / internal IP address of the modems.摸清局域網/內部的IP地址,該調製解調器。 They may be same like 1921.168.1.1.他們可能是相同的一樣, 1921.168.1.1 。
Check if the internal / LAN IP address of both (or multiple) modems are same.檢查,如果內部/局域網的IP地址,雙方(或多個)調製解調器是相同的。 In that use the web / telnet interface of the modems to configure one of the modems to have a different internal IP address preferably in different networks like 192.168.0.1 or 192.168.2.1 etc. If you are using multiple modems then you should configure each of them to have different subnets.在這方面使用Web /界面的Telnet的調製解調器配置一個調製解調器有不同的內部IP地址最好是在不同的網絡一樣, 192.168.0.1或192.168.2.1等,如果您是使用多個調製解調器,那麼你應該配置的每個他們有不同的子網。 This is important because now you can easily access the different modems from their web interface and you don’t have to bother connecting to a modem through a particular interface.這很重要,因為現在,您可以方便地訪問不同的調製解調器從他們的網頁介面,您不必理會連接到一個調製解調器通過一個特別的界面。 It is also important because now you can easily configure the interfaces to be associated with different netmasks / sub-network.這是也很重要,因為現在,您可以輕鬆地配置界面要與之關聯的不同netmasks /子網。

3. 3 。 Connect each modem to the computer using a different interface (eth0, eth1 etc.).每一個調製解調器連接到計算機上使用不同的接口(為eth0 , eth1等) 。 You may be able to use the same interface but this guide doesn’t cover that.您可以使用相同的接口,但本指南並不包括這一點。 In short you will make your life complicated using the same interface or even different virtual interface.在短期內您將讓您的生活複雜,使用相同的接口,甚至不同的虛擬接口。 My recommendation is that you should use one interface per modem.我的建議是,你應該使用一個接口的每調製解調器。 Don’t scrimp on cheap ethernet adapters.不節衣縮食的廉價以太網適配器。 This has the added benefit of redundancy should one adapter go bad down the road.這有一個好處,裁員應該一適配器去壞的下跌之路。

4. 4 。 Configure the IP address of each interface to be in the same sub-network as the modem.設定的IP地址,每個接口必須在相同的子網作為調製解調器。 For example my modems have IP addresses of 192.168.0.1 and 192.168.1.1.舉例來說,我有調製解調器的IP地址192.168.0.1和192.168.1.1 。 The corresponding addresses & netmasks of the interfaces are: 192.168.0.10 (netmask: 255.255.255.0) and 192.168.1.10 (netmask: 255.255.255.0).相應的地址& netmasks的接口是: 192.168.0.10 (網絡掩碼: 255.255.255.0 )和192.168.1.10 (網絡掩碼: 255.255.255.0 ) 。

5. 5 。 Find out the following information before you proceed with the rest of the guide:找到了下列資料,然後你開始與其餘的指南:

  1. IP address of external interfaces (interfaces connected to your modems). IP地址的外部接口(接口連接到您的調製解調器) 。 This is not the gateway address.這是不是網關地址。
  2. Gateway IP address of each broadband connections.網關的IP地址,每個寬帶連接。 This is the first hop gateway, could be your DSL modem IP address if it has been configured as the gateway following the tip below.這是首次合網關,可能是您的DSL調製解調器的IP地址,如果它已配置作為通往以下尖端下面。
  3. Name, IP address & netmask of external interfaces like eth1, eth2 etc. My external interfaces are eth1 & eth2.名稱, IP地址與網絡掩碼的外部接口一樣, eth1 , eth2等我的外部接口是eth1 & eth2 。
  4. Relative weights you want to assign to each connection.相對權重,你要分配給每個連接。 My Tata connection is 4 times faster than BSNL connection.我的塔塔方面是4倍,速度比印度BSNL方面。 So I assign the weight of 4 to Tata and 1 to BSNL.所以我轉讓的重量4日至塔塔和1至BSNL公司。 You must use low positive integer values for weights.您必須使用低的正整數,值的權重。 For same connection speeds weights of 1 & 1 are appropriate.為相同的連線速度的權重1 & 1恰當的。 The weights determine how the load is balanced across multiple connections.權重確定如何負荷是平衡的跨多個連接。 In my case Tata is 4 times as likely to be used as route for a particular site in comparison with BSNL.在我的情況塔塔是4倍,作為可能被用來作為該航線的某個特定網站在比較與BSNL公司。

Note: Refer to注:請參閱 Netmask guide網絡掩碼指南 for details on netmasks.詳情就netmasks 。

Optional step 可選步驟
Check the檢查 tips on configuring (A)DSL modems提示對配置(一) DSL調製解調器 . They are not required for using this guide.他們並不需要使用本指南。 However they are beneficial in maximizing your benefits.不過,他們有利於最大限度地在您的好處。

How to setup default load balancing for multiple ADSL / Cable connections如何設置默認負載平衡的多的ADSL /電纜連接

Unlike other guides on this topic I will use a real example - the configuration on our internal network.不像其他導遊關於這一主題的,我會使用一個真正的例子-配置對我們的內部網絡。 So to begin with here are the basic data for my network:因此,首先在這裡是基本數據,為我國網絡:

#IP address of external interfaces. #的IP地址,外部接口。 This is not the gateway address.這是不是網關地址。
IP1=192.168.1.10 ip1 = 192.168.1.10
IP2=192.168.0.10 ip2 = 192.168.0.10

#Gateway IP addresses. #網關的IP地址。 This is the first (hop) gateway, could be your router IP這是首次(合)網關,可能是您的路由器IP
#address if it has been configured as the gateway #地址,如果它已配置為網關
GW1=192.168.1.1 gw1 = 192.168.1.1
GW2=192.168.0.1 gw2 = 192.168.0.1

# Relative weights of routes. #的相對比重路線。 Keep this to a low integer value.保持這是一個低價值的整數。 I am using 4我使用的四
# for TATA connection because it is 4 times faster #塔塔方面,因為它是4倍,速度更快
W1=1 W1型= 1
W2=4 w2 = 4

# Broadband providers name; use your own names here. #寬頻供應商的名稱;使用自己的名字在這裡。
NAME1=bsnl name1 = BSNL公司
NAME2=tata name2 =塔塔

You must change the example below to use your own IP addresses and other details.你必須改變下面的例子使用自己的IP地址和其他細節。 Even with that inconvenience a real example is much easier to understand than examples with complex notations.甚至與不便,一個真正的例子是很容易理解的例子,較複雜的符號。 The example given below is copy-pasted from our intranet configuration.所舉的例子下面是複製-粘貼從我們的內部配置。 It works perfectly as advertised.它完美的工程作為廣告。

Note: In this step fail-over is not addressed.注:在這一步不超過並不是解決。 It is provided later with a script which runs on startup.這是稍後提供一個腳本運行的啟動。

First you need to create two (or more) routes in the routing table ( /etc/iproute2/rt_tables ).首先您需要創建兩個(或以上)的路線,在路由表( / etc/iproute2/rt_tables ) 。 Open the file and make changes similar to what is show below.打開該文件並做出變更,類似什麼是顯示下面。 I added the following for my two connections:我已將以下為我的兩個連接:

1 bsnl 1 BSNL公司
2 tata 二塔塔

To add a default load balancing route for our outgoing traffic using our dual internet connections (ADSL broadband connections from BSNL & Tata Indicom) here are the lines I included in rc.local file:要添加一個默認的負載平衡的路線,為我們即將離任的交通使用我們的雙網際網路連線( ADSL寬帶連接,從BSNL公司& Tata Indicom公司)在這裡,是線i包括在rc.local文件:

ip route add 192.168.1.0/24 dev eth1 src 192.168.1.10 table bsnl IP路由添加192.168.1.0/24開發eth1鋼骨混凝土192.168.1.10表BSNL公司
ip route add default via 192.168.1.1 table bsnl IP路由添加默認通過192.168.1.1表BSNL公司
ip route add 192.168.0.0/24 dev eth2 src 192.168.0.10 table tata IP路由添加192.168.0.0/24開發eth2鋼骨混凝土192.168.0.10表塔塔
ip route add default via 192.168.0.1 table tata IP路由添加默認通過192.168.0.1表塔塔
ip rule add from 192.168.1.10 table bsnl IP的規則添加從192.168.1.10表BSNL公司
ip rule add from 192.168.0.10 table tata IP的規則添加從192.168.0.10表塔塔
ip route add default scope global nexthop via 192.168.1.1 dev eth1 weight 1 nexthop via 192.168.0.1 dev eth2 weight 4 IP路由添加預設的範圍,全球nexthop通過192.168.1.1開發eth1重量1 nexthop通過192.168.0.1開發eth2重量4

Adding them to rc.local ensures that they are execute automatically on startup.他們添加到rc.local確保他們執行時自動啟動。 You can also run them manually from the command line.您也可以執行手動從命令列。

This completes the load balancing part.這完成負載平衡的一部分。 Let’s now see how we can achieve fail-over so the routes are automatically changed when one or more connections are down and then changed again when one or more more connections come back up again.讓我們現在看到的我們如何能實現故障排除,使這些路線自動改變,當一個或多個連接下來,然後再改變,當一個或多個連接更多的回來了一次。 To do this magic I used a script.為此魔術,我用一個腳本。

How to setup fail-over over multiple load balanced ADSL / Cable connections如何設定不超過多個負載平衡的ADSL /電纜連接

Please follow the steps below and preferably in the same order:請按照下列步驟進行,最好是在同一個命令:

  1. First首先 download the script下載腳本 which checks for and provides其中檢查,並提供 fail-over over dual ADSL / Cable internet connections不能超過超過雙的ADSL /纜線網際網路連線 and save it to /usr/sbin directory (or any other directory which is mounted available while loading the OS).並將它儲存為/ usr / sbin目錄(或任何其他目錄,這是展開數量有限,送完加載操作系統) 。
  2. Change the file permissions to 755:改變文件權限,以755 :
    chmod 755 /usr/sbin/gwping chmod 755為/ usr / sbin / gwping
  3. Open the file (as root) in an editor like vi or gedit and edit the following parameters for your environment:打開文件(如根)在編輯器一樣,六或gedit和編輯以下參數為您的環境:

    #IP Address or domain name to ping. # IP地址或域名,以平。 The script relies on the domain being pingable and always available腳本依賴於域被ping命令,並隨時
    TESTIP=www.yahoo.com testip = www.yahoo.com

    #Ping timeout in seconds #平超時秒數
    TIMEOUT=2超時= 2

    # External interfaces #外部接口
    EXTIF1=eth1 extif1 = eth1
    EXTIF2=eth2 extif2 = eth2

    #IP address of external interfaces. #的IP地址,外部接口。 This is not the gateway address.這是不是網關地址。
    IP1=192.168.1.10 ip1 = 192.168.1.10
    IP2=192.168.0.10 ip2 = 192.168.0.10

    #Gateway IP addresses. #網關的IP地址。 This is the first (hop) gateway, could be your router IP這是首次(合)網關,可能是您的路由器IP
    #address if it has been configured as the gateway #地址,如果它已配置為網關
    GW1=192.168.1.1 gw1 = 192.168.1.1
    GW2=192.168.0.1 gw2 = 192.168.0.1

    # Relative weights of routes. #的相對比重路線。 Keep this to a low integer value.保持這是一個低價值的整數。 I am using 4我使用的四
    # for TATA connection because it is 4 times faster #塔塔方面,因為它是4倍,速度更快
    W1=1 W1型= 1
    W2=4 w2 = 4

    # Broadband providers name; use your own names here. #寬頻供應商的名稱;使用自己的名字在這裡。
    NAME1=BSNL name1 = BSNL公司
    NAME2=TATA name2 =塔塔

    #No of repeats of success or failure before changing status of connection #沒有重複的成功或失敗之前,改變現狀的連接
    SUCCESSREPEATCOUNT=4 successrepeatcount = 4
    FAILUREREPEATCOUNT=1 failurerepeatcount = 1

    Note: Four consecutive success indicates that the gateway is up and one (consecutive) failure indicates that the gateway went down for my environment.注:連續四年的成功表明,該網關是和一(連續)的失敗表明,該網關則下跌為我的環境。 You may want to modify it to better match your environment.您可能要修改,使其更符合您的環境。

  4. Add the following line to the end of /etc/rc.local file:下面這一行添加到去年底,在/ etc / rc.local文件:
    nohup /usr/sbin/gwping & nohup在/ usr / sbin / gwping &

In the end my /etc/rc.local file has the following lines added in total:在結束我的/ etc / rc.local文件有下列行補充說:在總數:

ip route add 192.168.1.0/24 dev eth1 src 192.168.1.10 table bsnl IP路由添加192.168.1.0/24開發eth1鋼骨混凝土192.168.1.10表BSNL公司
ip route add default via 192.168.1.1 table bsnl IP路由添加默認通過192.168.1.1表BSNL公司
ip route add 192.168.0.0/24 dev eth2 src 192.168.0.10 table tata IP路由添加192.168.0.0/24開發eth2鋼骨混凝土192.168.0.10表塔塔
ip route add default via 192.168.0.1 table tata IP路由添加默認通過192.168.0.1表塔塔
ip rule add from 192.168.1.10 table bsnl IP的規則添加從192.168.1.10表BSNL公司
ip rule add from 192.168.0.10 table tata IP的規則添加從192.168.0.10表塔塔
ip route add default scope global nexthop via 192.168.1.1 dev eth1 weight 1 nexthop via 192.168.0.1 dev eth2 weight 4 IP路由添加預設的範圍,全球nexthop通過192.168.1.1開發eth1重量1 nexthop通過192.168.0.1開發eth2重量4
nohup /usr/sbin/gwping & nohup在/ usr / sbin / gwping &

An astute reader may note that the default setup with dual load balanced routing (7th line) is really not required as the script is configured to force routing based on the current status the very first time.一個精明的讀者也許注意到,默認設置具有雙重國籍的負載平衡路由(第七線) ,實在是不須作為腳本是設定為強制路由的基礎上,目前的狀況非常第一次。 However it is there to ensure proper routing before the script forces the routing for the first time which is about 40 seconds in my setup (can you tell why it takes 40 second for the first time?).但它的存在,以確保正確的路由之前,腳本勢力的路由為第一次是大約40秒,在我的安裝(你能否告訴,為何需要四零秒為第一次? ) 。

Concluding thoughts 總結的幾點思考
In the process of finding and coding the simple solution above, I read several documents on routing including the famous在這個過程中尋找和編碼,簡單的解決辦法以上的,我讀了若干文件,對路由,包括著名的 lartc how-to lartc如何到 (many of whose commands didn’t work as described on my Fedora Core system) & nano.txt among several others. (許多國家的命令,沒有工作的形容我的淺頂軟呢帽核心系統)及nano.txt之間的其他幾個。 I think I have described the simplest possible solution for load balancing and transparent failover of two or more DSL / Cable connections from one or more providers where channel bonding is not provided upstream (requires cooperation from one or more DSL providers); which is the most common scenario.我認為我剛才所說的最簡單可行的辦法,負載平衡和透明的故障的兩個或兩個以上的DSL /纜線數據機連接,從一個或多個供應商那裡通道綁定是沒有提供上游(需要合作,由一個或一個以上的DSL供應商) ;這是最常見的情況。 I would welcome suggestions and improvements to this document.我會歡迎的建議和改善本文件。

The solution has been well tested in multiple real and artificial load condition and works extremely well with users never realizing when a connection went down or came back up again.該解決方案已行之有效的在多個實時和人工負載條件下和工程非常好,與用戶從來沒有實現時,一個連接到或回來了一次。

Networking is a complex thing and it is conceivable that you may run into issues not covered here.網絡是一個複雜的事,這是可以想像,你可能會碰到的問題,並不包括在這裡。 Feel free to post your problems and solutions here.覺得免費發布您的問題和解決辦法在這裡。 However, while I would like to, I will not be able to debug and solve individual problems due to time constraints.不過,雖然我想,我將無法調試和解決個別問題,由於時間的限制。

I may however be able to offer useful suggestions to your unique problems.我可能,但能夠提供有用的建議,您獨特的問題。 It may however be noted that I respond well to它可能,但指出的是,我回應,以及以 Café Estima Blend™ by Starbuck早餐estima共混™由星巴克 s and move much quicker on my todo list. S和移動快得多對我的待辦事項列表。 It is also great as a這亦是偉大的作為 token of appreciation for my hard work心意,以示感謝我的辛勤工作 . The “velvety smooth and balanced with a roasty-sweet flavor this blend of coffees is a product of the relationships formed between” us. “ velvety順利和平衡與roasty甜的味道,這混合咖啡是一種產品的關係之間形成了”我們。

In a followup article I discussed how to在一個跟進名詞form; follow-up形容詞形式的文章我討論如何 configure single / dual / multiple ADSL / cable connections, firewall, gateway / NAT With Shorewall Firewall配置單/雙重/多重的ADSL /電纜連接,防火牆,網關/ shorewall的NAT防火牆 .