Re: Default outgoing IP address?

Matthew G. Marsh (mgm@paktronix.com)
Sun, 9 Dec 2001 17:13:57 -0600 (CST)


On Tue, 27 Nov 2001, Bill Davidsen wrote:

> On Mon, 26 Nov 2001, Oliver Xymoron wrote:
>
> > On a machine with multiple interfaces, is it possible to set the default
> > outgoing IP address to something other than the address for the interface
> > on the outgoing route?

Yes.

ip route add 10.1.1.0/24 via 192.168.1.1 src 172.16.1.1
^^^
The src parameter tells the routing code to use this address when sending
packets. The address only needs to be on the system. IE:

ip addr add 172.16.1.1/32 dev dummy0

And send the packets out of eth0.

> > For instance, a machine acts as a gateway, with addresses A and B, where A
> > faces the world (but isn't in DNS) and B is the canonical address.
> > Outgoing connections from the machine should appear to come from B.
>
> If you mean having multiple IP addresses on the same NIC, sure you can do
> that, see the section on DNAT in iptables. However, if you have multiple
> NICs, you do not want to send a packet from one which has the IP of the
> other, as your router is very likely to become confused and get its ARP
> table in a twist.

No need for DNAT. Just routing.

> You can force packets out one NIC or the other, usually using iproute, but
> I don't think that's what you have in mind, is it? In any case, doable.
>
> --
> bill davidsen <davidsen@tmr.com>
> CTO, TMR Associates, Inc
> Doing interesting things with little computers since 1979.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

--------------------------------------------------
Matthew G. Marsh, President
Paktronix Systems LLC
1506 North 59th Street
Omaha NE 68104
Phone: (402) 932-7250 x101
Email: mgm@paktronix.com
WWW: http://www.paktronix.com
--------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/