Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. 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, and when I wanna test it I need to run a few (5) instances on my linux/ubuntnu 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

share|improve this question

closed as off topic by splattne Feb 2 '12 at 11:47

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers 3

up vote 5 down vote accepted

It is not really clear what you are trying to do, but you can run multiple virtual machines (virtualization) on your PC to do your tests using a single machine.

If you want to have multiple IP addresses on the same physical interface, that is another thing. If this is what you want, you can do it the old way using ifconfig or the new way using ip addr add.

The old way:

$ sudo ifconfig eth0:0 your.ip.addr.ess netmask your.sub.net.mask up

The new way:

$ sudo ip addr add your.ip.addr.ess/mask.bits dev eth0

Of course, you need to replace your.ip.addr.ess with real value like and your.sub.net.mask with something like The mask.bits can be something like 24. You may need also to change the device name eth0. To view the IPs currently added, you can use ifconfig (old) or ip addr show (new).

share|improve this answer
yes I want multiple IP addresses on the same physical interface –  ePezhman Feb 2 '12 at 9:31

You need to create a subinterface inorder to assign a multiple ip to the same interface (for e.g. eth0). The command for assigning suppose 2 Ip address like & to interface eth0 will be as follows

# ifconfig eth0 netmask up

# ifconfig eth0:1 netmask up

After this restart the network

service network restart

I hope this answers your question...

share|improve this answer

I think you should look into loopback side.

insider@localhost:/$ sudo ifconfig eth0:3 netmask
insider@localhost:/$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:26:b6:ff:69:93  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::226:b6ff:feff:6993/64 Scope:Link
          RX packets:17987 errors:0 dropped:0 overruns:0 frame:20557
          TX packets:18061 errors:15 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13320368 (13.3 MB)  TX bytes:3143160 (3.1 MB)

eth0:2    Link encap:Ethernet  HWaddr 00:26:b6:ff:69:93  
          inet addr:  Bcast:  Mask:

eth0:3    Link encap:Ethernet  HWaddr 00:26:b6:ff:69:93  
          inet addr:  Bcast:  Mask:

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:285 errors:0 dropped:0 overruns:0 frame:0
          TX packets:285 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:54727 (54.7 KB)  TX bytes:54727 (54.7 KB)
share|improve this answer
Not only does the loopback interface have nothing to do with this, you didn't even link to the correct article. –  Ignacio Vazquez-Abrams Feb 2 '12 at 9:26 is also not a valid netmask (250 base 10 = 1111 1010 base 2; netmasks must be a continuous sequence of 1 bits followed by a continuous sequence of 0 bits), which is almost certainly the reason for the (admittedly incredibly unhelpful) SIOCSIFNETMASK: Invalid argument at the top. I don't know what does the fudging to a /24, and am too lazy to find out... :) –  Michael Kjörling Feb 2 '12 at 10:33
i know i'm a bit lazy :), but an error has been ignored –  insider Feb 5 '12 at 0:16

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