editor
699
edits
This is the support site for Andrews & Arnold Ltd, a UK Internet provider. Information on these pages is generally for our customers but may be useful to others, enjoy!
mNo edit summary |
(syntaxhighlight) |
||
Add a script in <tt>/etc/ppp/ip-up.d</tt> and in <tt>/etc/ppp/ipv6-up.d</tt> to put the routes in the per-interface tables:
<syntaxhighlight lang=bash>
#!/bin/bash
# ip-up.d/set-routes
ip route replace default dev ${PPP_IFACE} table ${PPP_IFACE}
</syntaxhighlight>
<syntaxhighlight lang=bash>
#!/bin/bash
# ipv6-up.d/set-routes
ip -6 route replace default dev ${PPP_IFACE} table ${PPP_IFACE}
</syntaxhighlight>
Add a script in <tt>/etc/ppp/ip-down.d</tt> and in <tt>/etc/ppp/ipv6-down.d</tt> to remove the per-interface routes when the PPP link goes down:
<syntaxhighlight lang=bash>
#!/bin/bash
# ip-down.d/remove-routes
ip route flush table ${PPP_IFACE}
</syntaxhighlight>
<syntaxhighlight lang=bash>
#!/bin/bash
# ipv6-down.d/remove-routes
ip -6 route flush table ${PPP_IFACE}
</syntaxhighlight>
Run the following script on boot:
<syntaxhighlight lang=bash>
#!/bin/bash
ip rule add from all table ppp1 prio 50001
ip -6 rule add from all table ppp1 prio 50001
</syntaxhighlight>
This uses iproute2's ip command to set up policy routing rules; the first set give you a firewall mark per line. (rules at prio 40000 and 40001). The last block (rules at 50000 and 50001) serves two purposes:
# It provides a fallback if you forget to add firewall marks in PREROUTING for some packets.
Finally, apply firewall marks in PREROUTING to choose your load balancing policy. For example, to simply load balances by alternating packets on each line:
<syntaxhighlight lang=bash>
for IPT in iptables ip6tables
do
$IPT -A PREROUTING ! -i ppp+ -m statistic --mode nth --every 2 --packet 1 -j MARK --set-mark 2
done
</syntaxhighlight>
[[Category:3rd Party Routers|Linux]]
|