Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
2  
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

3 Answers 3

up vote 3 down vote accepted

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

ip addr add 10.66.66.66/24 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 192.168.1.1
ifconfig eth0:2 192.168.1.2

etc.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.