With multiple addresses defined on several interfaces, you want to be able to tell your kernel "If I select such source address, please use that specific interface+gateway, not the default ones". You achieve this by configuring one routing table per outgoing interface, each routing table being identified by a number. The route selection process then happens in two phases. First the kernel does a lookup in the policy table (that you need to configure with ip rules). The policies, in our case, will be For such source prefix, go to routing table number x. Then the corresponding routing table is examined to select the gateway based on the destination address.
You need to configure several routing tables in the following manner:
Imagine you have two interfaces eth0 and eth1 with the following properties:
IP-Address: 10.1.1.2 Subnet-Mask: 255.255.255.0 Gateway: 10.1.1.1
IP-Address: 10.1.2.2 Subnet-Mask: 255.255.255.0 Gateway: 10.1.2.1
Thus, you need to configure the routing rules so that packets with source-IP 10.1.1.2 will get routed over eth0 and those with 10.1.2.2 will get routed over eth1.
The necessary commands are:
# This creates two different routing tables, that we use based on the source-address.
ip rule add from 10.1.1.2 table 1
ip rule add from 10.1.2.2 table 2# Configure the two different routing tables
ip route add 10.1.1.0/24 dev eth0 scope link table 1
ip route add default via 10.1.1.1 dev eth0 table 1
ip route add 10.1.2.0/24 dev eth1 scope link table 2
ip route add default via 10.1.2.1 dev eth1 table 2# default route for the selection process of normal internet-traffic
ip route add default scope global nexthop via 10.1.1.1 dev eth0
With this, your routing table should look like the following:
mptcp-kernel:~# ip rule show
0: from all lookup local
32764: from 10.1.2.2 lookup 2
32765: from 10.1.1.2 lookup 1
32766: from all lookup main
32767: from all lookup default
mptcp-kernel:~# ip route
10.1.1.0/24 dev eth0 proto kernel scope link src 10.1.1.2
10.1.2.0/24 dev eth1 proto kernel scope link src 10.1.2.2
default via 10.1.1.1 dev eth0
mptcp-kernel:~# ip route show table 1
10.1.1.0/24 dev eth0 scope link
default via 10.1.1.1 dev eth0
mptcp-kernel:~# ip route show table 2
10.1.2.0/24 dev eth1 scope link
default via 10.1.2.1 dev eth1
Doing the above each time by hand is very cumbersome. Some alternative automatic solutions are available:
Using the configuration scripts (Ubuntu/Debian-based systems)
/etc/network/if-up.d/ you can place scripts that will be executed each time a new interface comes up. We created two scripts:
* mptcp_up - Place it inside /etc/network/if-up.d/ and make it executable. * mptcp_down - Place it inside /etc/network/if-post-down.d/ and make it executable.
These scripts work most of the time. They use environment variables to configure the routing tables. If they do not work for you, please contact us on the mptcp-dev Mailing-List.
Automatic configuration with "Multihomed-Routing"
Kristian Evensen <email@example.com> developed a set of scripts that integrate well with existing Network Managers to properly configure the multihomed routing. Check it out at https://github.com/kristrev/multihomed-routing.
Automatic configuration with ConnMan
Dragos Tatulea <firstname.lastname@example.org> and Dongsu Park <dongsu@endocode> integrated support for Multipath TCP into ConnMan. Checkout his github repository for access to the source-code
Another way for Gentoo-based systems
Ondřej Caletka <Ondrej.Caletka@cesnet.cz> created a script for his Gentoo-based system. You can use his script from github. For any questions, please contact him directly.
DEPRECATED - Automatic configuration with MULTI
Kristian Evensen <email@example.com> created a daemon which automatically configures the correct routing tables. You can install his tool from github.