Questa pagina è nata dopo aver montato una ubuntu server con doppio linea di uscita.
Sono necessarie almeno due tabelle di routing.
Un ottima pagina di riferimento è questa di linux horizon , lui utilizza due tabelle di routing senza utilizzare la main table effettuando il mark dei pacchetti.
Routing due reti escono attraverso una connessione e altre due da un'altra
________
+-------------+ /
| ISP 1 | /
+-------------+ (RDS) +------+
| | gw 10.1.1.1 | /
+------+-------+ +-------------+ /
+----------------+ | eth1 | /
| | | | |
| Local networks +----+ Linux router | | Internet cloud
| | | | |
+----------------+ | eth2 | \
+------+-------+ +-------------+ \
| | ISP 2 | \
+-------------+ (ASTRAL) +------+
| gw 10.8.8.1 | \
+-------------+ \________
Il comandi da lanciare sono questi
Aggiungere le due tabelle di routing aggiuntive:
echo 1 RDS >> /etc/iproute2/rt_tables
echo 2 ASTRAL >> /etc/iproute2/rt_tables
Ecco il risultato del file dopo aver aggiunto le tabelle /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 RDS
2 ASTRAL
Adesso che abbiamo oltre alla tabella di routing main altre due tabelle aggiungiamo le rotte alle due tabelle.
For the RDS table:
ip route add default via 10.1.1.1 dev eth1 table RDS
ip rule add from 10.11.11.0/24 table RDS
ip rule add from 10.12.12.0/24 table RDS
For the ASTRAL table:
ip route add default via 10.8.8.1 dev eth2 table ASTRAL
ip rule add from 10.22.22.0/24 table ASTRAL
ip rule add from 10.33.33.0/24 table ASTRAL
To see the routing tables:
ip route show table ASTRAL
ip route show table RDS
ip route show table main # it's the same as "route -n" but in different format...
To see the routing tables:
ip rule show # all the rule list
ip rule show | grep ASTRAL # only for ASRAL
ip rule show | grep RDS # only for RDS
Routing usando le porte di dstinazione
To mark the packets that have the 22 and 80 as destination port we will use the MANGLE table…
iptables -A PREROUTING -t mangle -i eth0 -p tcp --dport 22 -j MARK --set-mark 1
iptables -A PREROUTING -t mangle -i eth0 -p tcp --dprot 80 -j MARK --set-mark 2
For the RDS table:
ip route add default via 10.1.1.1 dev eth1 table RDS # the same like in the first example
For the ASTRAL table:
ip route add default via 10.8.8.1 dev eth2 table ASTRAL # the same like in the first example
The next step is to have some routing rules based by the marked packets:
For the RDS:
ip rule add from all fwmark 1 table RDS
For the ASTRAL:
ip rule add from all fwmark 2 table ASTRAL
Source routing
Un'altra pagina interessante per il routing è questa
Bilanciamento
In quest'altra pagina spiega le tabelle di routing a livello superficiale è alla fine vi è anche un modo per fare il bilanciamento tra le connessioni. Anche se l'opzione del bilanciamento è sconsigliata come dai corsi networking della cisco per il rischio di fluttuazioni continue del carico.
Linux Advanced Routing & Traffic Control HOWTO
Pagina di Index totale per diverse funzionalità di routing sotto linux.
Vi è anche questo sito con diversi riferimenti in italiano
Ubuntu Failover router
questo articolo dice che bastano due comandi per relizzare un failover della connessione internet. Non l'ho provato ma penso funzioni