MultiWeb and Multiple Modems
The MultiWeb firmware allows the use of two modems at the same time and also provides a Load Balancing Manager to take care of directing traffic through each modem. This tutorial will show how to use two modems and how to set up the Manager.
Using two modems is very much like using a single modem in other ROOter versions. You have to set up the connection details in Modem->Connection Info and the rest is automatic. The tricky part is identifying which modem is designated as Modem #1 and which is Modem #2. This is critical, since each modem uses a different WAN interface and takes it's connection information from a different section of the Connection Info page.
If the router is already running when you plug in the modems then the first modem plugged in is designated as Modem #1 and the second modem plugged in is desiginated as Modem #2. This is simple to understand but can cause problems in other situations.
If the router is rebooted with the modems already plugged in then the modem in the lowest numbered USB port is detected first and becomes Modem #1. The other modem then becomes Modem #2. This may not be the same as if you plugged in the modems to an already running modem and problems can occur.
In order to make sure that the same modem is always detected as Modem #1 you must plug in the first modem in a running router into the lowest USB port.
If your router has two USB ports on it, or you are using a USB Hub, the method of determining which USB port has which number is the same. You plug in a modem to port and check the Status->System Log to see what port number is in use.
This shows the USB port, which is on a USB Hub, as being Port #3.
Plugging the modem into another port of the Hub gives this :
The USB port is Port #4.
To ensure that the modems are detected in the proper order always plug in the first modem to the lowest USB Port on the Hub or router. This will make sure that even if you reboot the router the modems will remain in the correct order for connection information and in the Load Balancing Manager.
Please note, if you have two modems plugged into the router and remove one of them you can plug it back into the same USB Port and have it reconnect. You can not plug it into a different port or plug a different modem into the original port. The scripts will not allow this and the connection will fail.
Load Balancing Manager
Load Balancing is the technique of dividing up the Internet traffic among the two modems plugged into your router. It allows you to specify that certain sites are only accessed through a specific modem or that one modem is preferred over another for these sites. You can also specify that certain devices on the network use only a specific modem.
Each modem plugged into the router uses a different named Network Interface. Modem #1 uses the interface named WAN1 and Modem #2 uses WAN2. The Load Balancing Manager allows you to manage how traffic from the devices on your network gets to various different Internet destinations using these network interfaces.
The Manager is an OpenWRT package called Mwan3 and it is accessed through Network->Load Balancing. It works strictly with the two network interfaces, WAN1 and WAN2, regardless of which modem is associated with that interface. This is another reason to know which modem is designated as Modem #1 (WAN1) and Modem #2 (WAN2).
By default, the Manager is set up with a basic set of information that should allow you to use it with minimum changes. We will look at each section of the Manager to see how it works and how you can modify it.
When you have two modems plugged in and connected you will see this in the Overview of the Load Balancing Manager.
To modify the Manager we must select the Configuration tab at the top.
The Manager is broken down into the Interface, Member, Policy and Rule sections. After each section is defined and configured it is used in the next section.
Interfaces are the modems we are using to connect to the Internet. They are defined by the network interface that they are associated with. In MultiWeb these interfaces are WAN1 (Modem #1) and WAN2 (Modem #2).
On this page we can define the network interfaces that we want to manage. It is already set up to handle the dual modem system and WAN1 and WAN2 are predefined.
The Manager determines if an interface (ie. modem) is connected by pinging a specified site or sites. By default this is the two Google DNS sites. By editing each interface's data you can customize the connection testing.
With our interfaces (modems) defined and configured we next can define the Members of our Manager. Members are a way to combine our network interfaces into different groups and with different rankings within that group. An interface can appear in multiple groups and have different rankings between groups.
Here we have defined four members which are combined into 2 groups. The metric of the Member can be considered the group number. wan1_m1_w3 and wan2_m1_w2 are members of group (metric) 1, while wan1_m2_w3 and wan2_m2_w2 are members of group 2.
With in a group the weight determines the ranking of each member. In group 1 wan1_m1_w3 has a higher weight than wan2_m1_w2 so it has a higher ranking within the group.
By editing the metrics and weights of each member you can customize how the members work.
With our members defined and grouped we can now look at Policies. Policies are used by the Manager to determine how traffic is sent through the different interfaces (modems).
Policies can be thought of as "pipes" that connect the router to the Internet. Each Policy "pipe" can be made up of one or more smaller pipes, which are the members we defined earlier. If a Policy has more than one member assigned to it then the group number and ranking of the members involved are used to direct traffic.
For traffic that will only go through WAN1 (Modem #1) we have defined a Policy named wan1_only. It consists of just the wan1_m1_w3 member. If WAN1 does not exist or is not connected then traffic that is supposed to go through this "pipe" is "blackholed" and just disappears.
Policies that have more than one member assigned to it follow certain rules.
The member with the lowest group (metric) number has precedence over members with higher group numbers.
In the case of the wan1_p_wan2_s policy this ensures that WAN1 is used first (wan1_m1_w3 is in group 1). If WAN1 is not connected then WAN2 will be used (wan2_m2_w2 is in group 2). If neither is connected the traffic is "blackholed".
For the wan2_p_wan1_s policy WAN2 is used first since the wan2_m1_w2 member is in group 1 and the wan1_m2_w3 member is in group 2.
If the members of the policy have the same group number (metric) then the members will load balance the traffic. Load-balancing members (with same group number) will distribute load based on assigned ranking (weight) in that group.
The wan1_wan2_lb policy has two members of the same group but different rankings. This will load balance the traffic with WAN1 receiving precedence over WAN2 since wan1_m1_w3 has a higher ranking (weight) than wan2_m1_w2. Again, if neither interface is connected the traffic is "blackholed".
To this point we have
- configured the network interfaces so the Manager can determine if the modem associated with the interface is actually connected.
- created different members associated with each interface and assigned them a group and ranking.
- created policies that are used to direct traffic to each interface based on the group and ranking of the members.
We can now use the policies we have created to direct specific traffic through each modem.
Rules are checked from top down and, if one applies to the traffic, the lower rules are ignored. If no rule applies to the traffic then normal router operation applies to it.
The rules that are defined here are based on certain assumptions just to demonstrate the Load Balancing Manager. Your rules will probably be different.
For this tutorial we assume that Modem #2 (WAN2) is a lower speed connection that has a high bandwidth plan. This is best for things like video streaming. Modem #1 (WAN1) is assumed to have a plan with a high speed but a lower bandwidth limit. This is best for general web browsing. If one connection is not available then we will use the other for all traffic.
Rule #1 is for YouTube. If traffic is headed to or from youtube.com (IP address 188.8.131.52), regardless if it is TCP, UDP or any other protocol, then use the wan2_p_wan1_s policy. This policy will use the modem associated with WAN2 as long as it is connected. This is Modem #2, which has a high bandwidth limit. If that modem is not connected then traffic will go in and out through WAN1 (Modem #1).
Rule #2 is the same as Rule #1 except that it is for traffic to and from netflix.com (IP Address 184.108.40.206). Modem #2 is used as long as it is connected and Modem #1 is used otherwise.
These two rules ensure that traffic to and from YouTube and Netflix are send, if possible, through the high bandwidth plan on Modem #2.
Rule #3 is used to direct all TCP traffic from a device on the network only through Modem #1. This device has an IP Address of 192.168.1.10. This type of rule can be used to force specific devices to use specific modems for their Internet connection. However, if this device is accessing YouTube or Netflix then the rules defined before this one (Rule #1 and Rule #2) will apply.
Rule #6 is used for all the rest of the traffic on the router. It will use the wan1_wan2_lb policy to load balance the traffic through both modems with Modem #1 receiving precedence.
For the Load Balancing Manager to operate at least one rule must be defined. The Manager is only in operation if two modems are present. Otherwise normal routing takes place.
It is possible to define what traffic uses what modem by
- Device IP Address
- Destination IP Address
- Source or Destination Port
- Network Protocol used
- Any combination of the above
This allows a great deal of customization of the Manager to fit your needs.