Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Dec 2000 11:39:25 +0000
From:      Tony Finch <dot@dotat.at>
To:        Michael Yeung <micyeung1@yahoo.com>
Cc:        net@FreeBSD.ORG
Subject:   Re: IP aliases and TCP socket
Message-ID:  <20001212113925.M76746@hand.dotat.at>
In-Reply-To: <20001211191746.25563.qmail@web4903.mail.yahoo.com>
References:  <20001211191746.25563.qmail@web4903.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Michael Yeung <micyeung1@yahoo.com> wrote:
>
>I noticed IP aliases restrict the alias IP address to be in the same
>subnet/network as the primary IP address. Is that a true restriction?

No. You configure aliases exactly as you would the primary address on
an interface without restriction, except that aliases within the same
network as an address previously added to the interface use a netmask
of -1.

>2) Assume IP aliases works for my needs as stated in question1. When
>I send a packet out over a TCP socket connection, how can I specify
>which address to be used as the source IP address (i.e. primary or
>alias address)?

bind(2) your socket to that address.

>3) Assume I can use IP aliases technique to receive packet destined
>to different IP addresses in the same application. If I am to use a
>TCP socket to retrieve the packet, how can I tell which IP address
>what the packet destined to (i.e. the primary or alias address)?

getsockname(2)

>Would packets for all addresses goes to the same socket or would it
>be through multiple sockets?

If you don't bind the listening socket to a specific IP address then
the former, else the latter.

>4) Is there direct API calls to the TCP/UDP for connection creation,
>sending and receiving? Or do I have to go thru the socket interface.

The socket interface is the most direct API there is (in userland).

I suggest you get a copy of Stevens "Unix Network Programming".
"TCP/IP Illustrated" and "Advanced Programming in the Unix
Environment" are also good investments.

Tony.
-- 
f.a.n.finch    fanf@covalent.net    dot@dotat.at
"You realize there's a government directive stating
that there is no such thing as a flying saucer?"


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001212113925.M76746>