Question Regarding IP Alias

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Apr 10 14:10:30 PDT 2003


On 2003-04-10 12:27, Sashikiran Rachakonda <sashi at cs.pdx.edu> wrote:
>
> Hi,i have a question regarding the IP Alias. If i bind my interface to 2
> ip addresses say
>
> 		1) ifconfig xl0 add w.x.y.z netmask 255.255.255.0
> 		2) ifconfig xl0 add p.q.r.s netmask 255.255.0.0
>
> Is there a way that i can force the packets coming-out of this
> interface to have ipSrc = p.q.r.s and not w.x.y.z. My question is is
> there a way that you can tell the interface to have the IPsrc set to
> the one we want to, for all packets coming out of this interface.

The default IP address that is used for packets that aren't explicitly
set to something different is the first address of the interface, IIRC.
'First' here being something that depends heavily on the order of the
ifconfig commands and the running kernel's code.

Instead of relying on factors like this that you cannot control
reliably, your programs should explicitly bind() a sockaddr_in structure
with the p.q.r.s address.  Then all outgoing packets of that socket will
have the correct address.

- Giorgos



More information about the freebsd-net mailing list