[TriLUG] multiple IP from the same network card?

Reginald Reed reginald at cisco.com
Wed Jun 18 21:35:06 EDT 2003


Yes this should work no problem at all.

Another route that was mentioned at least once is crafting the packets
yourself and spitting them out of any interface available without the
slightest regard to what the IP address or routing is bound to those
interfaces.  An excellent library to do this is libnet
(http://www.packetfactory.net/projects/libnet/).  We use libnet
extensively in my group at Cisco.  This is for the sending side.

To receive packets, you can use libpcap.  Things get much trickier using
these methods when you need things like TCP.  But depending on the scale
you need (we've done several tens of thousands of sessions like this).
After a few hundred IP's, using the stack generally doesn't cut it.

--Reggie

> -----Original Message-----
> From: trilug-admin at trilug.org 
> [mailto:trilug-admin at trilug.org] On Behalf Of Ken Mink
> Sent: Wednesday, June 18, 2003 4:50 PM
> To: trilug at trilug.org
> Subject: Re: [TriLUG] multiple IP from the same network card?
> 
> 
> On Wed, 2003-06-18 at 16:07, Mike Johnson wrote:
> > Chris Merrill [cmerrill at nc.rr.com] wrote:
> >  
> > > Are you sure?  In Java, for instance, you can "bind" a 
> socket to the 
> > > IP address of your choice.  I assume this is supported on all 
> > > platforms.
> > 
> > No, I'm not sure.  :)  Almost, though.  Like I said, I'm 
> willing to be 
> > proven wrong.  However, what kind of socket are you binding?  A 
> > server, or client?  I can see that being supported for a 
> > server/listening socket, but seems kinda odd for a client.
> > 
> > Try it, and let us know.
> > 
> > Mike
> 
> 
> I believe you can bind a client socket to a specific IP 
> address using the bind function, I assuming C here. I don't 
> have any code laying around to try it with, but I think these 
> three steps work;
> 
> sock = socket(domain, type, protocol);
> /* fill in my_addr struct with the ip address you want to use 
> */ bind(sock, *my_addr, addrlen); connect(sock, *serv_addr, addrlen);
> 
> Connect assigns the ip address and port if they have not been 
> previously specified. By calling bind before connect, you are 
> specifying your ip address and port. Be aware the port you 
> select may already be in use, so have appropriate error checking.
> 
> Ken
> -- 
> "They that can give up essential liberty to obtain a little 
> temporary safety deserve neither liberty nor 
> safety."--Benjamin Franklin " 'Necessity' is the plea for 
> every infringement of human liberty; it is the argument of 
> tyrants; it is the creed of slaves."--William Pitt 
> 
> 
> 




More information about the TriLUG mailing list