I'm doing some computer network homework and I'm supposed to develop some sort of Peer to Peer file sharing software, and when I wanna test it I need to run a few (5) instances on my linux/Ubuntu 11.10 . which means each one need to has a unique IP address. I heard I can do that but I dunno how. how can I have many IP addresses on a single computer? thanks
You need to create aliases of you network interface.
You have two options for doing this.
one is to create temporary aliases using
ifconfigcommand. The aliases setup this way will be lost upon a reboot and you will need to recreate those aliases;
if you need a more permanent solution, you can edit
/etc/network/interfacesfile and add alias' definitions there.
For more details on these two methods please visit Ubuntu Linux: Creating ethernet alias for eth0 network device.
If you only needed 2 instances of your program, I would recommende using a virtual machine, but for running five instances you will need 4 virtual machines which is not practical as it will almost halt your machine.
Actually this is not an answer to the question in the tilte, but to the question in the body!
The easiest way might be to just use different port numbers for your instances. Then all instances share the same ip address, you send the data to 127.0.0.1 via different ports. This should work well for your purposes.
client one listening on port 1234
client two listening on port 2345
client three listening on port 3456
So client one connects to client two via port 2345, to client three via port 3456, etc. etc.