You are not logged in.

#1 2009-10-04 22:24:59

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

[SOLVED]How to add multiple gateways in Arch

Hi, can someone please advise how to add multiple gateway address for multiple interfaces.

In my case I have two wired LAN cards. I use Arch network daemon to manage my NIC's.

I know in Gentoo it could be done through : 'gateway_ethX=( "default gw xx.xx.xx.xx dev ethX" )'

but doing so in arch wont connect to router/gateway.

Also in rc.conf it says :

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it

How to declare each route, and then how to list it in ROUTES?

I read the following thread:
http://bbs.archlinux.org/viewtopic.php?id=52992, but after adding the suggested lines in rc.conf and restarting the network it fails and says hostname not found.

Thanks.

Last edited by kapz (2009-10-08 18:53:39)


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#2 2009-10-05 10:49:48

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

Re: [SOLVED]How to add multiple gateways in Arch

Offline

#3 2009-10-05 17:27:46

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

oops..ma bad, I read that, but dunno how I missed it... big_smile

Thank you very much.


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#4 2009-10-05 17:38:56

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

Ok so it says that to add a route following lines should be added:

static-route1="-net 192.168.200.0/24 gw 192.168.100.15"

Now m a bit confused about assigning the route to a particular interface. So in above code is 192.168.200.0/24 a interfaces IP address, so instead of assigning route to a interface, route should be assigned to IP address and then it will autodetect the NIC according to IP?

Sorry but m really confused.

Last edited by kapz (2009-10-05 17:40:18)


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#5 2009-10-05 21:19:50

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

Re: [SOLVED]How to add multiple gateways in Arch

192.168.200.0/24 is a subnet (not an IP address) accessible via a gateway other than your default route.

A route to a directly connected subnet (eg, a second network card) will be added automatically when you assign the relevant IP address to the interface (eg, adding address 192.168.200.1/24) to eth1 will create a route for 192.168.200.0/24 via eth1).

Offline

#6 2009-10-06 06:21:07

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

Ok..just to simplify things, if my eth0 is 192.168.0.1 and eth1 is 192.168.1.14, now both have subnet mask 255.255.255.0. But I want to assign gateway address as 192.168.1.1 to eth1 only and dont want to asign any gateway to eth0 then how would I do that?

Like we can do it in any network manager(but it just activates one interface at a time):(


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#7 2009-10-06 06:54:17

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]How to add multiple gateways in Arch

As it says on that wiki page, the route declaration uses the route command's syntax, so have a look at man route to see how to specify a particular interface.

Offline

#8 2009-10-06 07:54:58

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

Re: [SOLVED]How to add multiple gateways in Arch

kapz wrote:

if my eth0 is 192.168.0.1 and eth1 is 192.168.1.14, now both have subnet mask 255.255.255.0. But I want to assign gateway address as 192.168.1.1 to eth1 only and dont want to asign any gateway to eth0 then how would I do that?

What is your gateway address? I think you maybe confusing your terminology between a 'gateway' and a 'route', and the difference between a locally/directly connected subnet versus a routed subnet.

Offline

#9 2009-10-06 18:15:09

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

Yes thats quite right...coz I thought gateway means route.
My gateway address to my ADSL router is 192.168.1.1.

Now if both of my interfaces that eth0 and eth1 go for default gw 192.168.1.1 then KDE freezes at startup, if no working internet connection is found. So need to keep one interface entirely for internet traffic and the other just to connect to other linux box/PC, eth1 for internet & eth0 for local Lan.


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#10 2009-10-06 21:55:36

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

Re: [SOLVED]How to add multiple gateways in Arch

In that case, your routing table should look something like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1

rc.conf:

eth0="eth0 192.168.1.14 netmask 255.255.255.0 broadcast 192.168.1.255"
eth1="eth1 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"
INTERFACES=(eth0 eth1)

# You may need to add 'dev eth1' to the end of this after '.1.1'
gateway="default gw 192.168.1.1"
ROUTES=(gateway)

Last edited by fukawi2 (2009-10-06 21:55:49)

Offline

#11 2009-10-07 14:43:54

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

ic!..Thanks a lot mate! smile

U know that is exactly what I wanted to know, so I'll take that, to assign a gateway(or let it be used by a specific interface) we add dev ethx after the gateway address, right?

Out of curiosity can you please explain or point me to a article as to why does the code differ in rc.conf file from distro to distro?? eg. slack and gentoo, i mean they all use the same linux kernel(assume we use same kernel for all three distros) So one has to learn shell scripting to understand that mystry?..

any answer would be much appreciated.


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

#12 2009-10-07 22:08:17

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

Re: [SOLVED]How to add multiple gateways in Arch

Well yes, they're the same kernel, but they're all compiled with different options and versions... But that's mostly irrelevant to how rc.conf varies. The differences there depend on how the distro devs write their startup scripts to interpret the configuration. Each distro has their own set of startup scripts to suit their needs/goals/desires and the rc.conf file changes to suit how they all work.

Offline

#13 2009-10-08 18:58:56

kapz
Member
Registered: 2009-03-26
Posts: 88
Website

Re: [SOLVED]How to add multiple gateways in Arch

Aha..so scripts it is! Now gotta learn that.

Anyways thanks a lot fukawi2, I really appreciate all of your help. thanks again.


I wonder how it would be like to use the rest 99% of my brain..:P

Registered Linux User: 487155

Offline

Board footer

Powered by FluxBB