You are not logged in.

#1 2010-11-29 05:54:14

kyle12
Member
Registered: 2009-10-29
Posts: 5

Multiple Gateways / IP Addresses.

Hey guys,

Basically I'm looking to configure my system to use Five Gateways/ IP ranges. Can I do this with rc.conf? Is there a way to specify which gateway each device goes through?

Thanks,
Kyle.

Offline

#2 2010-11-29 07:33:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Multiple Gateways / IP Addresses.

It's not easy, but it's possible.

Can you give us more information on the network topology?

Offline

#3 2010-11-29 08:41:28

kyle12
Member
Registered: 2009-10-29
Posts: 5

Re: Multiple Gateways / IP Addresses.

Why yes I can.

216.245.195.2 -> 216.245.195.6 is one range.
69.162.109.178 -> 69.162.109.182 is another.

Gateway is -1 at the start of the range, Broadcast is +1 at the end of the range.

Offline

#4 2010-11-29 20:43:20

TheCox
Member
From: Orlando, FL
Registered: 2010-02-23
Posts: 34

Re: Multiple Gateways / IP Addresses.

A default gateway is just where your computer sends outgoing packets that are not destined for a configured network. You can only have one.

You can configure multiple IPs(networks) like this:

eth0="eth0 216.245.195.2 netmask 255.255.255.248.0 broadcast 216.245.195.7"
eth0_0="eth0:0 69.162.109.178 netmask 255.255.248.0 broadcast 69.162.109.183"
INTERFACES=(lo eth0 eth0_0)

Offline

#5 2010-11-29 22:00:37

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Multiple Gateways / IP Addresses.

This is the article you want:
http://lartc.org/howto/lartc.rpdb.multiple-links.html
iproute2 is in [core] smile

TheCox -> You have only have 1 default gateway per route table. Fortunately, Linux allows you to have multiple route tables.

Offline

#6 2010-11-30 14:47:12

ammon
Member
Registered: 2008-12-11
Posts: 413

Re: Multiple Gateways / IP Addresses.

I used this like a script, but it is not working. Can you see what is wrong?

#!/bin/bash

# interface
IF0=lo
IF1=wlan0
IF2=wlan1

# ips
IP1=192.168.1.5
IP2=192.168.6.9

# gateways
P1=192.168.1.1
P2=192.168.6.1

# ip network
P0_NET=0.0.0.0
P1_NET=192.168.1.0
P2_NET=192.168.6.0

# create routing tables
ip route add $P1_NET dev $IF1 src $IP1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 src $IP2 table T2
ip route add default via $P2 table T2

# main routing table
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2

# default route preference
ip route add default via $P2

# routing rules
ip rule add from $IP1 table T1
ip rule add from $IP2 table T2

#ip route add $P0_NET     dev $IF0 table T1
#ip route add $P2_NET     dev $IF2 table T1
#ip route add 127.0.0.0/8 dev lo   table T1
#ip route add $P0_NET     dev $IF0 table T2
#ip route add $P1_NET     dev $IF1 table T2
#ip route add 127.0.0.0/8 dev lo   table T2 

ip route add default scope global nexthop via $P2 dev $IF2 weight 1
###########################################################

After executing this, wlan0 is still default interface.
nestat -ar
192.168.1.0     *               255.255.255.255 UH        0 0          0 wlan0
192.168.6.0     *               255.255.255.255 UH        0 0          0 wlan1
192.168.6.0     *               255.255.255.0   U         0 0          0 wlan1
192.168.1.0     *               255.255.255.0   U         0 0          0 wlan0
default         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0

And no traffic is going trought wlan1.

Last edited by ammon (2010-11-30 21:32:51)

Offline

#7 2010-12-01 02:01:33

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Multiple Gateways / IP Addresses.

I think you need 'ip route replace' rather than 'ip route add' in your default route command.

Offline

Board footer

Powered by FluxBB