This action might not be possible to undo. Are you sure you want to continue?
Assume you have a PC with Fedora Core 4 installed, acting as a router. You have a local network and 2 ISPs. Your local network Network: 192.168.1.0/24 Router's IP for this network: 192.168.1.254 ISP 1 Network: 10.0.1.0/24 Router's IP for this network: 10.0.1.1 Gateway: 10.0.1.254 ISP 2 Network: 10.0.2.0/24 Router's IP for this network: 10.0.2.1 Gateway: 10.0.2.254 Configuring Interfaces First, we configure interface eth0 for the local network: # ifconfig eth0 192.168.1.254/24 Then we configure interface eth1 for ISP 1: # ifconfig eth1 10.0.1.1/24 Next we configure interface eth2 for ISP 2: # ifconfig eth2 10.0.2.1/24 That's all for interface configuration, next we'll setup routing. Configuring Routing Tables When configuring multiple ISP, we need a separate routing table for each of them. We'll use the number 101 for the name of ISP 1's routing table. And 102 for the name of ISP 2's routing table. ISP 1 Routing Table Make sure we start with empty table # ip route flush all table 101 Add loopback network # ip route add 127.0.0.0/8 dev lo table 101
1.0.Add local network # ip route add 192.254 dev eth2 table 102 And we all set for ISPs routing tables.168.168. we'll need to decide.168.21 through 192.1. utilizing it's connection and balance the load of them? Case A: Split Access Assume we want some of the computers on our local network to use ISP 1.2.0/24 dev eth1 table 101 Add default gateway for ISP 1 # ip route add default via 10.0/24 dev eth2 table 102 Add default gateway for ISP 2 # ip route add default via 10. and some other use ISP 2? Or we just want to use both ISP.1.254 dev eth1 table 101 ISP 2 Routing Table Make sure we start with empty table # ip route flush all table 102 Add loopback network # ip route add 127.23 Thus we need to define ip rules. Their IP addresses are: 192.168.1.168.1.1. .126.96.36.199 And some other will use ISP 2.0. to classify the packets by source address.11 through 192.0. Their IP addresses are: 192. Fixed or Balanced? Next.0.0/24 dev eth0 table 102 Add the network of ISP 2 # ip route add 10. how we will be using those ISPs? Do we need split access.0.2.1.0/8 dev lo table 102 Add local network # ip route add 192. that is some of the computers on our local network will be using ISP 1.0/24 dev eth0 table 101 Add the network of ISP 1 # ip route add 10.
1.0.22 table 102 # ip rule add from 192. And all packets that will be going out through ISP 2 on interface eth2 will be using 10. You could guess what would happen if you put more weight on one gateway than the other.1. For ISP 1 # iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 10.1.21 table 102 # ip rule add from 192.168.1. here it is: # ip route add default via 10.1.168.0.2. * Edit * I forgot that this one also needs default gateway on the main table for packets originating from the router itself. jump to SNAT below. we only need to setup default gateway on the main routing table so packets will be using each ISP in a balanced way.168. we just have one last step to do and all will work as expected.23 table 102 That's it for ip rules.Rules for ISP 1 # ip rule add from 192.168.168.12 table 101 # ip rule add from 192.1 .168.13 table 101 Rules for ISP 2 # ip rule add from 192.11 table 101 # ip rule add from 192.254 weight 1 nexthop via 10.2. So all packets that will be going out through ISP 1 on interface eth1 will be using 10.0.254 weight 1 The key is to use same values for 'weight' parameter.1.1 as their source ip address.0.254 Case B: Load Balance For this we don't need ip rules. Remove the existing default gateway # ip route del default And add a load balanced gateway # ip route add default nexthop via 10.1.1 as their source ip address.1. SNAT We need to map local ip addresses to public ip address that's been assigned by our ISPs.188.8.131.52.
.1 And we all set.2.For ISP 2 # iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to 10.0.