Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I set two gateways for one ethernet card in linux?

Thanks a lot.

share|improve this question
up vote 3 down vote accepted

It depends on the linux distribution you're using. under debian like systems you have to change the contents of the file /etc/network/interfaces on rhel systems you have to edit the file /etc/sysconfig/networking-scripts/ifcfg- (where is the name of your ethernet card e.g. eth0)

you can add the entry "gateway" followed by the ip adress. as soon as you restart your network interface the routes will be added automatically to your routing table.

Like Michael already wrote you can also just add the corresponding route instead of editing the configuration files.

share|improve this answer

Take a look at the 'route' program on Linux (man route). If you are trying to accomplish static routing, something along the lines of:

route add [-host|-net] ...[etc]

What are you trying to do exactly? With some more details someone could probably lead you to exactly the solution you're looking for.

share|improve this answer

Let's assume you are using RedHat ES 5. Let's also assume that you want eth0 to route packets destined for to route through and packets destined for to route through

In /etc/sysconfig/network-scripts , create a file route-eth0 . In here, put: via via


/sbin/service network restart

And you should be good to go. You can check your current routing table with

netstat -nr

A good resource for RedHat can be found here:

share|improve this answer

The answer will depend on which distribution you are using.

Also, could you please add more detail about what you are trying to accomplish?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.