On Fri, Aug 24, 2001 at 01:10:46AM -0300, gervan@inter-k.com.ar wrote: > Hello zblaxell, > i read your article at > http://www.linuxarkivet.nu/mlists/linux-net/0107/msg00133.html Cool... > does it work if i have 2 public IPs in the same interface, with ip > aliasing? > i have: > eth0: 200.41.233.211 > eto0:1: 200.47.43.240 > eth1: private (for masquerading). > > Does your example work here? My example doesn't work, because it requires two interfaces; however, the basic principle is the same. Presumably you are doing this because you have two ISP's with two routers or switches that can tolerate being directly connected on a single Ethernet segment. (I don't have this situation--if I connect both ISP's to one Ethernet card, each will receive all of the traffic the other sends. This is bad. Very bad.) If this is not the case, e.g. you have two ISPs but you have two IP addresses at one of them, for a total of three IP's at two ISP's, use a mixture of this example and my previous one. Assume that you have two ISP's connected to eth0, like this: ISP #1: ip 1.2.3.4, netmask 255.255.255.0, gateway 1.2.3.1 ISP #2: ip 1.2.4.5, netmask 255.255.255.0, gateway 1.2.4.1 and on eth1: private network: 10.1.2.3, netmask 255.0.0.0, no gateway Then you set up the routing tables like this: # Private network gets its own routing table ip rule add pref 100 to 10.0.0.0/8 table 100 ip route add 10.0.0.0/8 dev eth1 table 100 # ISP #1 gets their own routing table ip rule add pref 200 from 1.2.3.4 table 101 ip route add default via 1.2.3.1 table 101 # ISP #2 gets their own routing table ip rule add pref 200 from 1.2.4.5 table 102 ip route add default via 1.2.4.1 table 102 # Everything else in the main routing table. ip route add 1.2.3.0/24 dev eth0 ip route add 1.2.4.0/24 dev eth0 # Note that "dev eth0" shouldn't be necessary, # but I haven't tested this... ip route add default \ nexthop via 1.2.3.1 dev eth0 \ nexthop via 1.2.4.1 dev eth0 # Start it all ip route flush cache Note that this is almost identical to my previous example, except that instead of using two devices, you use one device with two gateways. Regardless, you always use the source address to select which routing table, and you give each ISP their own routing table. Any route query that doesn't have an associated source address gets the default, which assigns a route to one of the ISP's gateways at random. If you have an entire subnet, rather than a single IP address, use this form: # Your machine has subnet 1.2.3.0/24, with the ISP's gateway # at 1.2.3.1: ip rule add pref 200 from 1.2.3.0/24 table 100 ip route add 1.2.3.1 dev eth0 This assumes you have the entire 1.2.3.0/24 address space, except for the gateway. -- Zygo Blaxell (Laptop) <zblaxell@feedme.hungrycats.org> GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
Attachment:
pgp00028.pgp
Description: PGP signature