LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Two gateways? (https://www.linuxquestions.org/questions/linux-networking-3/two-gateways-891094/)

MarcusWebb1966 07-11-2011 08:21 AM

Two gateways?
 
Hi

Trying to set up a server in Debian that has one network card but two separate gateways on it (i.e. in two separate subnets). I've been trying and failing miserably in this:

I'd like to have one network on eth0
10.45.36.15 Address
10.45.36.4 Gateway
255.255.255.0 Netmask

and the other on eth0:2
10.197.82.124 Address
10.197.82.117 Gateway
255.255.255.240 Netmask

It's probably the easiest thing in the world, but what the hell is the route command I need to get this working? I've tried
Code:


route add -net 10.197.82.124/28 gw 10.197.82.117 dev eth0:2

to be hit with
Code:

SIOCADDRT: No such process
Oh yes, and it has to be a permanent route, so if I reboot or the power fails, it comes back.

TIA wonderful people

Dani1973 07-11-2011 08:46 AM

10.197.82.124/28 is not a network but a IP address.

your network address should be : 10.197.82.112
and broadcast : 10.197.82.127
useable IP addresses : 10.197.82.113 to 10.197.82.126

PS : hope I got that right long time I did subnet calculation ^^

MarcusWebb1966 07-11-2011 08:50 AM

Sorry, my bad - I'm trying to get the network address to be .124 as per the original question, hence the strange /28 on there. I believe(d) that put me in the right range as per your subnet calculation.

Dani1973 07-11-2011 09:16 AM

But still your route wouldn't make sense because it's a directly connected network and it should be in the routing table by default.

What are you really trying to accomplish?

MarcusWebb1966 07-11-2011 09:44 AM

I'm trying to get the server to respond to a particular website address on this IP (has to be this IP, no others will do).

As a result the server has to send back packets via a gateway that is in the same subnet, hence me asking for a second gateway for the network card.

So theoretically it looks like this:
Code:

iface eth0 inet static
    address 10.45.36.15
    netmask 255.255.255.0
    network 10.45.36.0
    broadcast 255.255.255.0
    gateway 10.46.36.4

iface eth0:1 inet static
    address 10.45.36.215
    netmask 255.255.255.0
    broadcast 255.255.255.0

iface eth0:2 inte static
    address 10.197.82.124
    netmask 255.255.255.240
    network 10.197.82.112
    gateway 10.197.82.117

Does that look right for an /etc/network/interfaces file? and what's the corresponding route you need to add to make said network (eth0:2) run?

Regards

Dani1973 07-11-2011 10:20 AM

Your configurations is asking for 2 default gateways that can't be done.
You cannot have 2 default gateways!

MarcusWebb1966 07-11-2011 10:28 AM

Well, tbh, I didn't think it was a flier but someone assured me it could be done. Oh well, you live and learn. Thank you Dani1973!

Dani1973 07-11-2011 11:03 AM

You are not lost yet, when configuring things in /etc/network/interfaces you specify default gateways.

You need routing with conditions, I have no experience with it but with iproute you can specify things like what comes in on one interface goes out on that interface.

PS : is it only me or is LQ about to 'explode' ? (lots of timeouts when coming on this board)

MarcusWebb1966 07-11-2011 12:02 PM

Oh, that would be an interesting exercise - mind you I tried doing this so that I didn't have to figure out how to configure routing with iproute. ;-) Our previous server that was working on doing this (as in "Leave it alone, it's working!" never had its config saved and on reboot all our routing connections disappeared into the ether never to be seen again.

Can someone with exposure to iproute point me in the general direction of what I'm supposed to be looking at/doing? I'm normally reasonably smart at figuring these things out myself...

And again, Many thanks Dani1973...

Dani1973 07-11-2011 08:35 PM

check the cli history on the old server maybe you will be lucky and it's in there -> /root/.bash_history

MarcusWebb1966 07-12-2011 03:01 AM

Unfortunately in the process of trying to get it back, we updated the system and borked it a little and now it doesn't even boot....

Dani1973 07-12-2011 05:16 AM

That's where a live CD can be handy ;)


All times are GMT -5. The time now is 01:55 PM.