From owner-freebsd-questions Tue Feb 13 17:18:51 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id RAA23080 for questions-outgoing; Tue, 13 Feb 1996 17:18:51 -0800 (PST) Received: from wdl1.wdl.loral.com (wdl1.wdl.loral.com [137.249.32.1]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id RAA23075 for ; Tue, 13 Feb 1996 17:18:49 -0800 (PST) Received: from miles.sso.loral.com (miles.wdl.loral.com) by wdl1.wdl.loral.com (5.x/WDL-2.4-1.0) id AA11948; Tue, 13 Feb 1996 17:18:06 -0800 Received: by miles.sso.loral.com (4.1/SSO-SUN-2.04) id AA19055; Tue, 13 Feb 96 20:17:10 EST Date: Tue, 13 Feb 1996 20:17:09 -0500 (EST) From: Richard Toren X-Sender: rpt@miles To: "Eric J. Schwertfeger" Cc: questions@freebsd.org Subject: Re: Q: programming sockets source address? In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org Precedence: bulk Eric, If I read your question correctly, you want to creat multiple outbound connections, each from a different source IP address, but all on the same host box and physical interface. I had to do this under OSF/1 with > 60 IP addresses needed. Here is what I did as a quick fix. ( I haven't tried this under FreeBSD, but the man pages says it should work.) 1. Study 'ifconfig' man page, and the '-alias' option. 2. Write small program that takes interface and ip address as string args. netalias.c main(int argc, char *argv[]) { /* argv[1]=interface name argv[2]=new ip address */ char buffer[512]; sprintf (buffer,"ifconfig %s -alias %s", argv[1],argv[2]); return system (buffer); } (this code as example, fix as needed) 3. Make program setuid root so that it has permissions to add a new alias IP address. 4. From main program, determine needed IP; then system ("netalias le0 244.234.2.2"); // should add alias bind specific ip (244.234.2.2) in socket rather than 'inaddrany' This can all be done more elegantly, but this can be codded and tested faster than I can type this mail message. I eventually ended up with a daemon I called SNE for "Schizophrenic Network Entity". It proxied for any given IP address and port; doing listens, connects and passing data. Sort of a software router and spoofer. You may have to play some games with the routes so that replys to your aliases are routed back to the originating machine. Hope this helps. I thought it was rather neat when I found we didn't have to buy 60 machines ==================================================== Rip Toren | The bad news is that C++ is not an object-oriented | rpt@miles.sso.loral.com | programming language. .... The good news is that | | C++ supports object-oriented programming. | | C++ Programming & Fundamental Concepts | | by Anderson & Heinze | ====================================================