Auf Basis der MAC-Adresse der Fritze, über die das Paket reinkam, ein Connection Mark an die Verbindung schreiben:
iptables -t mangle -A INPUT -i eth0 -m mac --mac-source a7:bc:5d:23:53:a3 -j CONNMARK --set-xmark 0x1/0xffffffff
iptables -t mangle -A INPUT -i eth0 -m mac --mac-source e3:c0:f9:f1:8d:76 -j CONNMARK --set-xmark 0x2/0xffffffff
Das Connection Mark in ein Routing Mark umschreiben:
iptables -t mangle -A OUTPUT -m connmark --mark 0x1 -j MARK --set-xmark 0x1/0xffffffff
iptables -t mangle -A OUTPUT -m connmark --mark 0x2 -j MARK --set-xmark 0x2/0xffffffff
Alternative Routingtabellen pro Fritze anlegen (habe ich immer als post-up in /etc/network/interfaces
):
ip route add default via 192.168.1.1 table 1
ip route add default via 192.168.1.2 table 2
Routing Policies anlegen, die die Routingtabelle aufgrund des gesetzten Routing Mark auswählen (habe ich ebenfalls immer als post-up in /etc/network/interfaces
):
ip rule add fwmark 1 table 1
ip rule add fwmark 2 table 2
(Das wars schon, glaube ich.)
Konfiguration am Interface in /etc/network/interfaces: