Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I got a single ethernet connection to a network but with multiple ips.
Because of this, I am using virtual network interfaces like this:

auto intern
iface intern inet static
        address ...
        netmask ...
        gateway ...

auto intern:1
iface intern:1 inet static
        address ...
        netmask ...
        gateway ...

I need to configure which IP should be used by default for outgoing traffic.

How can I do that?

share|improve this question

You need to use the option -b src.ip.addr.ess. For other tools, you need to at the manual to check for the right option. Also, telnet and ssh use the same option -b.

share|improve this answer
I am not looking for all those interface options, but for a way I can set the DEFAULT for all network-connected tools. – Zulakis Sep 24 '12 at 7:12
By default, each program/tool will use the "primary" interface address. I am not aware of a way to change this behavior globally unless you change this primary address. – Khaled Sep 24 '12 at 7:29
How can I set the primary interface? What other effects could changing it have? – Zulakis Sep 24 '12 at 8:18
the primary interface is the first interface it finds on the subnet, otherwise its the first interface it finds which is on the subnet where the gateway is. – Flash Sep 24 '12 at 9:38
"It finds"... There must be a way on how to set this. – Zulakis Sep 24 '12 at 10:24

I need to configure which IP should be used by default for outgoing traffic.

Make it the first one listed in /etc/network/interfaces for that interface.


iface intern inet static
    address # This one is it
share|improve this answer
This does not work. The second one (out of three) is getting used. – Zulakis Sep 24 '12 at 18:11
OK, then please edit your question to provide a more realistic view of what your interfaces file looks like. – Michael Hampton Sep 24 '12 at 18:12
It it not that different, just intern, intern:1 and intern:2 - intern:1 is getting used – Zulakis Sep 24 '12 at 18:13
up vote 0 down vote accepted

It looks like the first sub-interface (intern:1) of the first interfac eis getting used as default device. It's a little bit weird that not just the primary interface (intern) is getting used.

If anyone has a fix for this, feel free to post.

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.