Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:network:wan:multiwan:mwan3 [2023/04/22 11:04] – jamesmacwhite | docs:guide-user:network:wan:multiwan:mwan3 [2024/05/17 08:30] – [nft2ipset init script] jamesmacwhite | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== mwan3 (Multi WAN load balancing/ | ====== mwan3 (Multi WAN load balancing/ | ||
| - | * 22.03: Latest release: [[: | + | * 23.05: Latest release: [[: |
| + | * 22.03: Latest release: 2.11.7 | ||
| * 21.02: Latest release: 2.10.13-1 | * 21.02: Latest release: 2.10.13-1 | ||
| - | * 19.07 or older: No longer supported or maintained. | ||
| ==== About mwan3 ==== | ==== About mwan3 ==== | ||
| Line 57: | Line 57: | ||
| Ensure no other multiple WAN or policy routing packages are installed such as '' | Ensure no other multiple WAN or policy routing packages are installed such as '' | ||
| + | |||
| ==== OpenWrt version ==== | ==== OpenWrt version ==== | ||
| - | **Using the latest [[:# | + | === 23.05 === |
| - | On 22.03.2, you [[https:// | + | The mwan3 package is mostly unchanged between |
| - | The old stable 19.07 branch should also work but it has an older version of mwan3 which does not include some newer features and fixes. It was also discovered there were a few 4.14 kernel | + | **Known |
| - | Older branches before 19.07 are no longer supported. | + | * [[https:// |
| - | You can find the current open issues for mwan3 on the [[https:// | + | === 22.03 === |
| - | ==== IPv6 support | + | 22.03 switched to firewall4/ |
| - | <WRAP center info 100%> | + | **Known issues:** |
| - | Using mwan3 with IPv6 requires additional configuration such as IPv6 masquerading through methods like NETMAP or NAT6. This is currently not implemented in mwan3 directly and requires additional configuration. | + | |
| - | </ | + | |
| - | mwan3 does support IPv6 interfaces, but there are few guidelines you need to follow in order to configure | + | There are a few regressions between 2.10 and 2.11 identified with sticky rules and ipset. |
| + | An issue with fwmark and tunnel connections can cause traffic | ||
| - | | + | |
| - | | + | |
| - | | + | * < |
| + | | ||
| - | NAT6 is potentially a controversial suggestion for many, but realistically without BGP, it is often required for IPv6 multihoming. Currently mwan3 does not implement any IPv6 masquerading as part of it's configuration. This is something that needs to be configured outside of mwan3 itself. | + | === 21.02 === |
| - | The [[# | + | **No longer supported.** |
| - | === Disable | + | The version of mwan3 in 21.02 is 2.10.13-1, it has a lot of improvements over the version in 19.07 for both performance and stability. |
| - | You can prevent mwan3 from routing | + | For those running some form of tunnel based protocol e.g. L2TP, 6in4 and IPv6 traffic |
| + | |||
| + | **Known issues:** | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | Older versions beyond | ||
| + | |||
| + | You can find the current open issues for mwan3 on the [[https:// | ||
| ==== Hardware requirements ==== | ==== Hardware requirements ==== | ||
| Line 116: | Line 125: | ||
| option ifname ' | option ifname ' | ||
| </ | </ | ||
| + | |||
| + | ===== Installation ===== | ||
| + | ==== Command line (SSH) ==== | ||
| + | |||
| + | <code bash> | ||
| + | opkg update | ||
| + | opkg install mwan3 | ||
| + | opkg install luci-app-mwan3 | ||
| + | </ | ||
| + | |||
| + | '' | ||
| + | |||
| + | <WRAP center info 100%> | ||
| + | For routers using 22.03 or above the default firewall uses firewall4/ | ||
| + | </ | ||
| + | |||
| + | **For 22.03 or later:** | ||
| + | |||
| + | <code bash> | ||
| + | opkg install iptables-nft | ||
| + | opkg install ip6tables-nft | ||
| + | </ | ||
| + | |||
| + | ==== Web interface (LuCI) === | ||
| + | * Go to System -> Software | ||
| + | * click " | ||
| + | * In the " | ||
| + | * For 22.03: Install the '' | ||
| + | |||
| + | === Restart LuCI or reboot if needed === | ||
| + | |||
| + | To ensure the new menu item for mwan3 appears, logout of your existing session and restart the service hosting the LuCI interface i.e. uhttpd or just reboot the router. | ||
| + | |||
| + | * Go to System > Startup | ||
| + | * click the " | ||
| + | * Login into the web interface again. | ||
| + | |||
| + | A new menu entry " | ||
| + | |||
| + | ==== Upgrading ==== | ||
| + | |||
| + | If there is a newer version of mwan3 available, you can upgrade mwan3 through either opkg or LuCI. | ||
| + | |||
| + | < | ||
| + | opkg upgrade mwan3 | ||
| + | </ | ||
| + | |||
| + | Or through LuCI: **System** -> **Software** -> **Updates** | ||
| + | |||
| + | Your existing configuration will not be modified and instead if there any changes from the default, these will be able to be viewed in a '' | ||
| + | |||
| + | ==== IPv6 support ==== | ||
| + | |||
| + | <WRAP center info 100%> | ||
| + | Using mwan3 with load balancing or failover routing policies for IPv6 requires additional configuration such as NETMAP, NPTv6 or NAT66. None of these methods are currently implemented in mwan3 directly and hence requires additional configuration. | ||
| + | </ | ||
| + | |||
| + | **Using IPv6 with mwan3:** | ||
| + | |||
| + | - Newer versions of mwan3 have better IPv6 support, ensure you are running a supported OpenWrt version, as various IPv6 related areas have been addressed in recent versions. | ||
| + | - You will need to split your WAN network interfaces, so one interface has your IPv4 WAN and another for the IPv6 WAN. A common example convention is wan and wan6 (default with OpenWrt), along with an additional WAN interfaces such as wanb and wanb6 etc. Your IPv6 interface can be an alias interface in most cases. You then define each interface in mwan3 with the address family of either '' | ||
| + | - You will likely need to implement some form of IPv6 masquerading such as NETMAP or NPTv6 or [[docs: | ||
| + | |||
| + | NETMAP, NPTv6 and NAT66 all are configuration options that can work with mwan3, but it is up to you to implement the IPv6 configuration required. mwan3 does not currently implement any IPv6 masquerading by itself. | ||
| + | |||
| + | The [[# | ||
| + | |||
| + | === Disable mwan3 from routing IPv6 traffic === | ||
| + | |||
| + | You can prevent mwan3 from routing IPv6 traffic by declaring '' | ||
| ===== Pre-configuration ===== | ===== Pre-configuration ===== | ||
| Line 143: | Line 222: | ||
| === Routers using Distributed Switch Architecture (DSA) === | === Routers using Distributed Switch Architecture (DSA) === | ||
| - | From 21.02 onwards | + | From 21.02 onwards |
| - Go to **Network > Interfaces** and select the Devices tab. Click configure on the br-lan device. | - Go to **Network > Interfaces** and select the Devices tab. Click configure on the br-lan device. | ||
| Line 324: | Line 403: | ||
| This is the IP of // | This is the IP of // | ||
| - | |||
| - | |||
| - | ===== Installation ===== | ||
| - | ==== Command line (SSH) ==== | ||
| - | |||
| - | <code bash> | ||
| - | opkg update | ||
| - | opkg install mwan3 | ||
| - | opkg install luci-app-mwan3 | ||
| - | </ | ||
| - | |||
| - | '' | ||
| - | |||
| - | ==== Web interface (LuCI) === | ||
| - | * Go to System -> Software | ||
| - | * click " | ||
| - | * In the " | ||
| - | |||
| - | === Restart LuCI or reboot if needed === | ||
| - | |||
| - | To ensure the new menu item for mwan3 appears, logout of your existing session and restart the service hosting the LuCI interface i.e. uhttpd or just reboot the router. | ||
| - | |||
| - | * Go to System > Startup | ||
| - | * click the " | ||
| - | * Login into the web interface again. | ||
| - | |||
| - | A new menu entry " | ||
| - | |||
| - | ==== Upgrading ==== | ||
| - | |||
| - | If there is a newer version of mwan3 available, you can upgrade mwan3 through either opkg or LuCI. | ||
| - | |||
| - | < | ||
| - | opkg upgrade mwan3 | ||
| - | </ | ||
| - | |||
| - | Or through LuCI: **System** -> **Software** -> **Updates** | ||
| - | |||
| - | Your existing configuration will not be modified and instead if there any changes from the default, these will be able to be viewed in a '' | ||
| ===== mwan3 configuration ===== | ===== mwan3 configuration ===== | ||
| - | The mwan3 configuration consists of five section elements, namely: | + | The mwan3 configuration consists of five main sections: |
| - | + | ||
| - | * Globals | + | |
| - | * Interfaces | + | |
| - | * Members | + | |
| - | * Policies | + | |
| - | * Rules | + | |
| - | + | ||
| - | Essentially the configuration can be summarised to the following. Globals are settings that apply to all of mwan3, interfaces are configured in mwan3 to be tracked and relate to the interface names present in your network configuration. For routing rules, one or more members must be defined targeting a specific interface, which in turn are assigned to a policy and a policy is assigned to one or more rules. | + | |
| - | + | ||
| + | * Globals - Global settings that apply to mwan3 overall. | ||
| + | * Interfaces - Network interfaces to be used/ | ||
| + | * Members - For a network interface to be used in mwan3, it must be defined as a member, which can then be used in policies. | ||
| + | * Policies - How the traffic should be routed according to the metric value and weight set in the member configuration. This allows you to define configurations like load balancing/ | ||
| + | * Rules - Defining one or more specific routing rules according to the defined policy set. A variety of rules can be configured using source/ | ||
| ==== Globals configuration ===== | ==== Globals configuration ===== | ||
| Line 521: | Line 556: | ||
| **Key points about rules:** | **Key points about rules:** | ||
| - | * Rules specify which traffic will use a particular policy | + | * Rules specify which traffic will use a particular policy. |
| - | * Rules are based on IP address, port or protocol | + | * Rules are based on IP address, port or protocol. |
| - | * Rules are matched from top to bottom | + | * Rules are matched from top to bottom. |
| - | * Rules below a matching rule are ignored | + | * Rules below a matching rule are ignored. |
| - | * Traffic not matching any rule is routed using the main routing table | + | * Traffic not matching any defined |
| - | * Traffic destined for known (other than default) networks is handled by the main routing table | + | * Traffic destined for known (other than default) networks is handled by the main routing table. |
| - | * Traffic matching a rule where all interfaces for that policy are down will be blackholed | + | * Traffic matching a rule where all interfaces for that policy are down will be blackholed. |
| - | * Rule names may contain characters A-Z, a-z, 0-9, _ and no spaces | + | * Rule names may contain characters A-Z, a-z, 0-9, _ and no spaces. |
| - | * Rules may not share the same name as configured interfaces, members or policies | + | * Rules may not share the same name as configured interfaces, members or policies. |
| ^ Name ^ Type ^ Required ^ Default ^ Description ^ | ^ Name ^ Type ^ Required ^ Default ^ Description ^ | ||
| Line 569: | Line 604: | ||
| For rules that require a large amount of destination IP addresses, it is recommended to use ipset as this more optimised to group large amounts of IP addresses, or CIDR ranges. | For rules that require a large amount of destination IP addresses, it is recommended to use ipset as this more optimised to group large amounts of IP addresses, or CIDR ranges. | ||
| - | === ipset and sticky | + | === Sticky |
| - | Stickiness | + | Sticky (or sticky sessions) can be enabled on a per-rule basis and lets you route a new session over the same WAN interface as the previous session, as long as the time between the new and the previous session is shorter then the specified |
| + | |||
| + | By default mwan3 treats all https traffic with a sticky rule. | ||
| <code bash> | <code bash> | ||
| - | config rule 'youtube' | + | config rule 'https' |
| option sticky ' | option sticky ' | ||
| - | option timeout '300' | + | option |
| + | option proto ' | ||
| + | option use_policy ' | ||
| + | </ | ||
| + | |||
| + | With sticky set to 1, this rule now uses sticky sessions. When a packet for a new session matches this rule, its source IP address and interface mark are stored in an ipmark. When a packet for a second new session from the same LAN host within the timeout | ||
| + | |||
| + | === ipset support === | ||
| + | |||
| + | <WRAP center important 100%> | ||
| + | ipset functionality is broken in 23.05 due to the '' | ||
| + | </ | ||
| + | |||
| + | ipset is designed to store multiple IP addresses in a single collection, while being performant and easier to maintain. Common usages of ipset include storing large amounts of IP addresses or ranges in a single set as well as conditional routing by domain. As routing ultimately works at the IP layer, being able to use ipset with domain based policies is useful for many websites or services which use multiple IP addresses or large Content Delivery Networks which means the IP address of that domain is constantly changing, individually adding these IP addresses would become unmanageable very quickly, ipset can help maintain this for you. | ||
| + | |||
| + | A set can be populated manually, by a DNS resolver (triggered by a DNS lookup), or your own script. Rules enabled with ipset option will check for the existence of the destination address in the ipset chain defined in the rule to determine what routing needs to take place. If the destination address is found, the packet will be routed according to the policy, otherwise the ipset policy will not apply. | ||
| + | |||
| + | <code bash> | ||
| + | config rule 'youtube' | ||
| option ipset ' | option ipset ' | ||
| + | option sticky ' | ||
| option dest_port ' | option dest_port ' | ||
| option proto ' | option proto ' | ||
| Line 583: | Line 639: | ||
| </ | </ | ||
| - | With sticky | + | **Tip:** ipset rules also support |
| - | **Stickiness is on a per rule basis. With this example, all traffic from LAN hosts will use the same WAN interface | + | The example creates an ipset rule for a collection called youtube, with an additional |
| - | The option | + | For having |
| - | If the ipset chain does not already exist, mwan3 will create the ipset set for you. For this to work you need to configure a rule for dnsmasq in your ''/ | + | **dnsmasq: |
| + | |||
| + | **Note:** dnsmasq-full is required for ipset functionality. | ||
| <code bash> | <code bash> | ||
| Line 603: | Line 661: | ||
| </ | </ | ||
| - | You will then need to restart dnsmasq | + | Add more domains by separating each domain with a ''/'' |
| + | |||
| + | **AdGuard Home:** | ||
| + | |||
| + | Add to ''/ | ||
| + | |||
| + | <code yaml> | ||
| + | dns: | ||
| + | | ||
| + | - youtube.com/ | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Add more domains by separating each domain with a '','' | ||
| + | |||
| + | Restart your DNS resolver and make a DNS lookup | ||
| + | |||
| + | <code bash> | ||
| + | ipset -L youtube | ||
| + | </ | ||
| + | |||
| + | If all is working correctly, you should see the resolved IP address or addresses in the ipset collection. | ||
| + | |||
| + | Be aware if the domain has been recently resolved by your DNS resolver, it may return a cache response which may not hit the ipset collection, clear the DNS cache and confirm your lookup is not a cached result. | ||
| ==== Default configuration example ==== | ==== Default configuration example ==== | ||
| Line 810: | Line 891: | ||
| **Changes in version 2.10.0:** | **Changes in version 2.10.0:** | ||
| - | '' | + | '' |
| + | |||
| + | <code bash> | ||
| + | mwan3 use < | ||
| + | </ | ||
| + | |||
| + | **Ping using the primary WAN interface: | ||
| + | |||
| + | <code bash> | ||
| + | mwan3 use wan ping -4 google.co.uk | ||
| + | </ | ||
| + | |||
| + | **iperf3 using the secondary WAN interface: | ||
| + | |||
| + | <code bash> | ||
| + | mwan3 use wanb iperf3 -4 -c speed.nimag.net -R | ||
| + | </ | ||
| **Changes in version 2.8.11:** | **Changes in version 2.8.11:** | ||
| Line 1254: | Line 1352: | ||
| option family ' | option family ' | ||
| option use_policy ' | option use_policy ' | ||
| + | </ | ||
| + | |||
| + | ==== nft2ipset init script ==== | ||
| + | |||
| + | Due to the default firewall (fw4) now being based on nftables (rather than iptables), the ipset functionality commonly used in conjunction with dnsmasq and mwan3 no longer works in 23.05 releases. This is due to mwan3 not being fully compatible with nftables and requiring iptables compatibility/ | ||
| + | |||
| + | You will need to use nfset with dnsmasq for ipset polices to be created, which mwan3 only supports at this time. mwan3 currently does not support nfset in rules directly, hence the need to create ipset policies. | ||
| + | |||
| + | For help with this init script, please message @Kishi on the forum thread and also thank them if you found this useful! | ||
| + | |||
| + | The script is [[https:// | ||
| + | |||
| + | Installation instructions: | ||
| + | |||
| + | < | ||
| + | wget -O / | ||
| + | chmod +x / | ||
| + | service nft2ipset enable | ||
| + | service nft2ipset start | ||
| </ | </ | ||