Question Regarding IP Alias

Martin A. Brown mabrown-linux-net at
Wed Apr 2 09:35:37 PST 2003

Under linux, it is not difficult to accomplish this:

# ip link set dev $DEV up
# ip addr add dev $DEV w.x.y.z/24
# ip addr add dev $DEV p.q.r.s/16
# ip route add $DESTINATION via $GATEWAY src p.q.r.s

If an application requests the use of IP address w.x.y.z, there is no way
for the routing code to select the preferred address, but if the
application leaves the source address selection to the kernel, you can use
the "src" parameter as indicated above.

See the iproute2 manual (ip-cref) for a more detailed description of the
source address selection process.  This is HTML output of the TeX source
which is included in the iproute2 distribution.

And for the record, while linux continues to provide backward compatible
support for traditional IP aliases (eth0:0, eth0:1), these are merely
conventions for representing the IPs which are available on a given
interface.  To see a list of the IPs available on a given interface, you
should use:

# ip addr show dev $DEV

So, Sashi, why did you cross-post this on freebsd and linux lists?  Which
are you using?  Naturally, your use of the "xl0" interface name suggests
that your example is a BSD box.

Good luck with your problem,


 : 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
 : 		2) ifconfig xl0 add p.q.r.s netmask
 : 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.
 : Thanx in Advance,
 : --Sashi.
 : -
 : To unsubscribe from this list: send the line "unsubscribe linux-net" in
 : the body of a message to majordomo at
 : More majordomo info at

Martin A. Brown --- SecurePipe, Inc. --- mabrown at

More information about the freebsd-questions mailing list