Operating System - Linux
1831374 Members
3581 Online
110025 Solutions
New Discussion

two default route - help me

 
fabiolpi
New Member

two default route - help me

Hi

How do I add two default route with two different gateways on different interfaces with different priorities:

eth0 192.168.0.1 Intranet
eth1 192.168.1.1 internet router for internal QMail
eth2 192.168.2.1 internet adsl for Proxy

for the eth1 the gateway must be 192.168.1.254
for the eth2 the gateway must be 192.168.2.254

proxy and navigation must use adsl (192.168.2.254)

and

my email server only the router (192.168.1.254)

my firewall it´s ok...

I need help....

thanks

Fabio Leonardo Jung
from Brasil :
4 REPLIES 4
Stuart Browne
Honored Contributor

Re: two default route - help me

I'm going to assume that your mail server is on a fixed address?

In that case, just route that host address through the second interface, instead of a 'default route'.

i.e.

ip route add dev eth2 via 192.168.1.254

(or the older format 'route add -host gw 192.168.1.254 eth2').
One long-haired git at your service...
Ivan Ferreira
Honored Contributor

Re: two default route - help me

You can add the default gateway for every interface in the interface configuration file, /etc/sysconfig/network-scripts/ifcfg-ethX.

You should add a line:

GATEWAY=x.y.w.z

For every interface and restart the network services.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Devesh Pant_1
Esteemed Contributor

Re: two default route - help me

Fabio,
you can add a route but you cannot have two default routes since deafault in tech terms by itself tells you that it is the default when there is nothing available.
So have one default route and add the second route
thanks

DP
Tvs
Regular Advisor

Re: two default route - help me

Hai ,

you can do one thing .you can set two gateway for one interface with different priority

like

route add net x.x.x.x(n/w ) netmask x.x.x.x xx.xx.xx.xx(gateway) 0 - first gateway

route add net x.x.x.x(n/w ) netmask x.x.x.x xx.xx.xx.xx(gateway) 1 - second priority