From: Willy Tarreau <willy@w.ods.org>
To: Tomas Szepe <szepe@pinerecords.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [OT] ipv4: how to choose src ip?
Date: Thu, 5 Dec 2002 21:58:17 +0100 [thread overview]
Message-ID: <20021205205817.GB21070@alpha.home.local> (raw)
In-Reply-To: <20021205190054.GE23877@louise.pinerecords.com>
On Thu, Dec 05, 2002 at 08:00:54PM +0100, Tomas Szepe wrote:
> Suppose I have two IP addresses from the same subnet on the same
> interface, and this interface also happens to be what my default
> gateway is on, like so:
>
> /sbin/ifconfig eth1 213.168.178.209 netmask 255.255.255.192 \
> broadcast 213.168.178.255
> /sbin/ifconfig eth1:0 213.168.178.210 netmask 255.255.255.192 \
> broadcast 213.168.178.255
> /sbin/route add default gw 213.168.178.193
Honnestly, the simplest way to deal with aliases and source addresses is to
forget ifconfig/route and replace them with iproute2 (ftp.inr.ac.ru), which
lets you specify the source address among many other settings. Really a
wonderful and cleanly coded tool.
In your case, you'd call it this way :
ip addr add 213.168.178.209/26 dev eth0
ip addr add 213.168.178.210/26 dev eth0
ip route add default via 213.168.178.193
When several addresses can resolve for the source, the first one is used by
default, so in the above case, it will be .209. But it's easy to specify the
other one :
ip route add default via 213.168.178.193 src 213.168.178.210
In fact, you can even set the source of another interface, which is very useful
on point-to-point connections above private networks.
I really don't understand why modern distros don't use it by default, and still
prefer prehistoric ifconfig and route. These ones are extremely limited
regarding what the kernel can do.
Cheers,
Willy
next prev parent reply other threads:[~2002-12-05 20:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-05 19:00 Tomas Szepe
2002-12-05 20:37 ` Richard B. Johnson
2002-12-05 20:56 ` Brad Hards
2002-12-05 21:38 ` Tomas Szepe
2002-12-06 4:25 ` Ben Greear
2002-12-06 9:06 ` Andrew McGregor
2002-12-06 15:13 ` Richard B. Johnson
2002-12-05 20:58 ` Willy Tarreau [this message]
2002-12-05 21:39 ` Tomas Szepe
2002-12-06 15:27 ` Mark Frazer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021205205817.GB21070@alpha.home.local \
--to=willy@w.ods.org \
--cc=linux-kernel@vger.kernel.org \
--cc=szepe@pinerecords.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®