First, I set up a new aliased ethernet port on the Linux box, using the Gnome System Settings/Network tool. I gave this IP address 192.168.0.1 (no default gateway).
Then I connected to the new router, and changed its IP address to 192.168.0.250. I physically moved it onto the eth0 network. Finally I telnetted to it and set up its own routes, as follows:
D-Link> ip route addrom index 1
D-Link> ip route addrom name gbit
D-Link> ip route addrom set 192.168.3.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok
D-Link> ip route addrom index 2
D-Link> ip route addrom name mbit
D-Link> ip route addrom set 192.168.1.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok
D-Link> ip route addrom index 3
D-Link> ip route addrom name dirty
D-Link> ip route addrom set 192.168.2.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok
This set up the following static routes:
Dest FF Len Device Gateway Metric stat Timer Use RN
192.168.0.0 00 24 enet0 192.168.0.250 1 041b 0 1150
192.168.1.0 00 24 enet0 192.168.0.1 1 001b 0 0
192.168.2.0 00 24 enet0 192.168.0.1 1 001b 0 0
192.168.3.0 00 24 enet0 192.168.0.1 1 001b 0 445
Then I altered the routes on the Linux box as follows:
ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1 table ISP1
ip route add default via 192.168.2.5 table ISP1
ip route add 192.168.0.0/24 dev eth0 src 192.168.0.1 table ISP2
ip route add default via 192.168.0.250 table ISP2
ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1
ip route add default via 192.168.2.5
ip rule add from 192.168.2.1 table ISP1
ip rule add from 192.168.0.1 table ISP2
I also set up static routes for some IP addresses I wanted to reach via one or other ISP (e.g. their DNS servers).
That all works - I can connect in from outside via either of the two routers (I have set up identical NAT mappings on both). I can easily switch to the secondary router like this:
ip route del default
ip route add default via 192.168.0.250
I am now considering load balancing between the two routers. I think the commands to do this would be:
ip route del default
ip route add default scope global nexthop via 192.168.2.5 dev eth0 weight 6 nexthop via 192.168.0.250 dev eth0 weight 1
No comments:
Post a Comment