Date: Tue, 13 Feb 1996 20:17:09 -0500 (EST) From: Richard Toren <rpt@miles.sso.loral.com> To: "Eric J. Schwertfeger" <ejs@bfd.com> Cc: questions@freebsd.org Subject: Re: Q: programming sockets source address? Message-ID: <Pine.SUN.3.91.960213195751.19005B-100000@miles> In-Reply-To: <Pine.BSF.3.91.960212135045.22730B-100000@harlie.bfd.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 |
====================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.960213195751.19005B-100000>
