Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing some computer network homework and I'm supposed to develop some sort of Peer to Peer file sharing software. I want to test it and run a few (five) instances on Ubuntu 11.10, which means each one needs to have a unique IP address.

I heard I can do that, but I don't know how.

How can I have more than one IP address on a single computer?

share|improve this question
You may want to consider VMs for this, so that the packets are sent across some sort of real-looking network instead of just being routed around within the same OS instance. – Ignacio Vazquez-Abrams Feb 2 '12 at 9:14
So wait, do you have five different machines running Ubuntu? Or do you only have one machine? In the latter case, this is going to be difficult, and not practically possible. Consider setting up five virtual machines. – slhck Feb 2 '12 at 9:15
@slhck: No, it can be done easily enough. The real issue is if it can be considered an adequate test of the software. – Ignacio Vazquez-Abrams Feb 2 '12 at 9:18
VMs are best option. @slhck: this is Linux. Binding several IPs to one physical interface is doable and easy. – m0skit0 Feb 2 '12 at 9:22
I have only one ubuntu – ePezhman Feb 2 '12 at 9:30
up vote 3 down vote accepted

Hm. The easiest way to set additional ip addresses is just by

ip addr add dev eth0 

and the likes.

Then, your file sharing software should bind to those IP addresses. The question is - would they be routed out in such a way all of them would have access to the internet? or to each other? This can be a really fun exercise in iptables.

share|improve this answer
Is there a limit to the number of IP addresses you can add to a device in this way? On my end I've been using the interfaces definitions with eth0:0, eth0:1, etc. which is limited to 254 IPs per NIC. – Alexis Wilke Jun 23 '13 at 5:03

This should do the trick:

ifconfig eth0:1
ifconfig eth0:2


share|improve this answer

In a local network you have multicast and you really do not need any sort P2P. Maybe coordinating multicast well would help a lot (router will multiply packets, no extra file serving from clients)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .