Answer the question
In order to leave comments, you need to log in
Bundling internet links to specific networks in Debian Wheezy?
Peer-to-peer network /24, the network has a server and three Internet gateways (routers).
You need to taxi traffic to certain subnets (subnets, within city peering) with consolidation through these gateways, let the rest of the traffic through _gateway1_.
Before that, static routing was used: ~30% of networks through _gateway1_, another 30% through _gateway2_, etc.
Now balancing using ip route is used:
#!/bin/bash
ip route add 31.135.208.0/21 scope global nexthop via 192.168.1.1 dev eth0 weight 1 \
nexthop via 192.168.1.2 dev eth0 weight 1 \
nexthop via 192.168.1.4 dev eth0 weight 1
ip route add 37.110.208.0/21 scope global nexthop via 192.168.1.1 dev eth0 weight 1 \
nexthop via 192.168.1.2 dev eth0 weight 1 \
nexthop via 192.168.1.4 dev eth0 weight 1
...
ip route add 217.30.160.0/20 scope global nexthop via 192.168.1.1 dev eth0 weight 1 \
nexthop via 192.168.1.2 dev eth0 weight 1 \
nexthop via 192.168.1.4 dev eth0 weight 1
Answer the question
In order to leave comments, you need to log in
So everything is the same. Three iproute tables with default gates 192.168.1.1, 192.168.1.2 and 192.168.1.4 respectively + default gate 192.168.1.1 in the main table. Well, in the rules you need to do a match on the destination subnet. You can simply duplicate the rules for marking for each of the subnets
Here the only option is to do round-robin marking of packets to these subnets. Simply duplicating the rules will not work - only the first one will work, and the rest will not come to pass. Pure means of iproute also cannot resolve this - multipath routing works with streams, not with individual packets.
The scheme is more or less standard: three tables, each with a default route. As well as three rules for routing by label. In iptables write something like this:
iptables -t mangle -A PREROUTING --dst <subnet/prefix> -m statistic --mode nth --every 3 -j MARK --set-mark 0x1
iptables -t mangle -A PREROUTING --dst <subnet/prefix> -m mark ! --mark 0x1 -m statistic --mode nth --every 2 -j MARK --set-mark 0x2
iptables -t mangle -A PREROUTING --dst <subnet/prefix> -m mark ! --mark 0x1 -m mark ! --mark 0x2 -j MARK --set-mark 0x3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question