how to add multiple static ip addresses in ubuntu 12.04?

1

i want to add multiple addresses ( 20 addresses) to a single linux box. To test the master slave configuration i want to setup this one.so these 20 ip's will act as slaves. i know how to add the virtual ip, but after adding that networking is not going to restart.

    auto eth0:1

    iface eth0:1 inet static

    address 192.168.249.150

    netmask 255.255.0.0

    network 192.168.0.0

    broadcast 192.168.255.255

    gateway 192.168.0.232

    dns-nameservers 8.8.8.8

i added like this up to 20 addresses. then i try to restart the network. but it is saying that

RTNETLINK answers: File exists Failed to bring up eth0:1.

can i know the exact procedure to do this.

Ramkee

Posted 2014-08-09T05:21:50.967

Reputation: 269

Answers

1

If you deal with ifconfig directly it will be far more clear imho. And you don't need gateway for each ip - this will mess everything. Broadcasting 192.168.255.255 can generate chaos too.

Look in /etc folder to find out where exactly is the startup file in Ubuntu. Search for rc.local

First try in the console to add the addresses and if everything is OK just copy/paste the commands in the rc.local.

try this:

for i in 249 248 247 246; do 
  ifconfig eth0:$i 192.168.$i.150/24;
done

This will generate interfaces eth0:246, eth0:247, eth0:248, eth0:249 with addresses 192.168.246.150, 192.168.247.150, 192.168.248.150 and 192.168.249.150. All netmasks will be 255.255.255.0 (that's what /24 means).

Later if you want to drop all this interfaces you can use

for i in 249 248 247 246; do 
  ifconfig eth0:$i 192.168.$i.150 down;
done

And if you don't want a loop you can type commands one by one. for more info look at the ifconfig man page

LHristov

Posted 2014-08-09T05:21:50.967

Reputation: 131