Subject: Control of source IP address
To: None <netbsd-help@NetBSD.ORG>
From: David Maxwell <dwm@reptiles.org>
List: netbsd-help
Date: 09/17/1996 18:36:21
Okay, I'm back again (and still stuck)...

I'm trying to control the source IP address of packets generated by a client
application under NetBSD.

The machine is configured with two addresses, ed2 at 205.206.248.71 and
sl0 at 205.206.248.72

I've done the normal route add 205.206.248.72 localhost 
and the arp -s 205.206.248.72 x:x:x:x:x:x:x:x pub commands, and the
machine responds to both addresses properly and I've now placed the following
hack into /usr/bin/ftp...

Starting at line 116 of ftp.c:

	hisctladdr.sin_port = port;
{
char ipr[100] = "205.206.248.72" ;
struct sockaddr_in myadr;
inet_aton(ipr,&myadr.sin_addr);
bind(s,&myadr,sizeof(myadr));
}
	while (connect(s, (struct sockaddr *)&hisctladdr, sizeof (hisctladdr)) < 0) {

My intention is to bind to the '72' address and have that be the source address
for the outgoing ftp connection, but the server I connect to is still logging
the connection from 205.206.248.71

Have I misunderstood the steps involved to bind directly to the address I want?
Should I be doing the bind with a copy of the sockaddr_in structure used to
create the socket + the sin_addr set?

Thank You

							David Maxwell
							david@vex.net