Subject: Re: Controlling Source IP address
To: Charles M. Hannum <mycroft@mit.edu>
From: David Maxwell <david@vex.net>
List: netbsd-help
Date: 09/09/1996 12:43:44
I guess I was overly concise. I'd like to be able to modify a client application
 - say telnet - running on a NetBSD machine so that all the IP traffic it
generates
comes from a specific IP address (which belongs to the system. I have no
need to be
able to spoof addresses here, only to use valid ones assigned to the box.)

Suppose I have multiple IP addresses for incoming connections - aliased
addresses on
ed0 for virtual hosting web and mail domains perhaps. Now I want to initiate
a telnet
(or other client app) connection out and have it appear to come from one of
the aliased 
addresses instead of the primary one. For that matter, I need to have
multiple simultaneous
connections going out to different addresses which have different apparent
sources from
the aliased IPs on ed0

I'd like to avoid the process running as root for the usual reasons (e.g.
sendmail) but the
SOCK_RAW option was the only method I'd discovered so far, and while
setsockopt's man page
describes some of the options which can be set at the socket level ( SO_* )
I can't find an
equivalent for the TCP + IP level options.

As for binding, I can check the apache source to understand binding to
incoming connections
only for certain IPs, but my reading of the /usr/src/sys/netinet/ip_output.c
source had me 
thinking that the outgoing source address will be set to the primary address
for the 
interface.

Thanks for the feedback on 100BT as well. I didn't realize that the drivers
are compatible
with the 10BT drivers. (Is that a misstatement?)

At 10:44 PM 10/09/96 -0400, you wrote:
>
>David Maxwell <david@vex.net> writes:
>
>> 
>> Could someone tell me if there is a way - on a NetBSD system - programming
>> at the 
>> application level - to send packets out an ethernet interface and which
of the
>> interface's aliased IP addresses to use as the source for the packets?
>
>That's not quite specific enough, but here are a few ways:
>
>* Just bind a socket with the appropriate IP address and use it
>normally.
>
>* Use the `raw IP' interface (SOCK_RAW) with the `IP_HDRINCL' option
>and build the IP headers yourself, with whatever address you want.
>
>* Use BPF to send raw Ethernet packets.
>
>The latter two options require the program to run as root.
>
>> Also, are there any 100BT ethernet cards supported in 1.1 and 1.2? (Any
>> NetBSD port)
>
>I think both the SMC series (based on the DEC chips) and the 3COM
>3c59X series sport 100BT versions.
>
>