-   Linux - Networking (
-   -   Two gateways? (

MarcusWebb1966 07-11-2011 08:21 AM

Two gateways?

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 Address Gateway Netmask

and the other on eth0:2 Address Gateway 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

route add -net gw dev eth0:2

to be hit with

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 is not a network but a IP address.

your network address should be :
and broadcast :
useable IP addresses : to

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:

iface eth0 inet static

iface eth0:1 inet static

iface eth0:2 inte static

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?


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 09:44 PM.