How to set up multiple IP addresses?

Solution 1:

You need to create aliases of you network interface.

You have two options for doing this.

  1. one is to create temporary aliases using ifconfig command. The aliases setup this way will be lost upon a reboot and you will need to recreate those aliases;

  2. if you need a more permanent solution, you can edit /etc/network/interfaces file 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.

Solution 2:

In NetworkManager's applet you can choose Manual instead of DHCP.

Then, you can add to the list more than one address.

Solution 3:

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.

E.g.:

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.