Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having issues adding a second IP address to one interface. Below is my /etc/networking/interfaces

   # The loopback network interface
auto lo
iface lo inet loopback

#eth0 is our main IP address
auto eth0
iface eth0 inet static
 address 198.58.103.*
 netmask 255.255.255.0
 gateway 198.58.103.1

#eth0:0 is our private address
auto eth0:0
iface eth0:0 inet static
 address 192.168.129.134
 netmask 255.255.128.0

#eth0:1 is for www.site.com
auto eth0:1
iface eth0:1 inet static
 address 198.58.104.*
 netmask 255.255.255.0
 gateway 198.58.104.1

When I run /etc/init.d/networking restart, I get a fail error about bringing up eth0:1:

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

Any reason this would be? I didn't have any problems with I first set up eth0 and eth0:0.

share|improve this question
    
Remove the second gateway 198.58.104.1 –  Matt Dec 5 '12 at 22:52
    
For future readers, I did still have to reboot even after I removed the second gateway. –  tubaguy50035 Dec 5 '12 at 23:05
    
/etc/init.d/networking restart has always been problematic for me. Always best to do a full machine reboot. –  Matt Dec 6 '12 at 2:57
add comment

2 Answers

up vote 1 down vote accepted

EDIT:

The problem is you have 2 default gateway's defined. You need to remove one of them. I would think the one on the eth0:1 device.

The file exists error is being thrown by attempting to add the default route again which is already in place.


Firstly, I presume the * as the host number is a valid number and not literally a '*'?

Now try it this way. I suspect there is a problem with the parsing of the auto line in the startup scripts - just a hunch, I haven't looked.

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#eth0 is our main IP address
auto eth0
iface eth0 inet static
 address 198.58.103.*
 netmask 255.255.255.0
 gateway 198.58.103.1
 # Put your nameserver address here!
 dns-nameservers x.x.x.x 

#eth0:0 is our private address
auto eth0:0
iface eth0:0 inet static
 address 192.168.129.134
 netmask 255.255.128.0

#eth0:1 is for www.site.com
auto eth0:1
iface eth0:1 inet static
 address 198.58.104.*
 netmask 255.255.255.0
 # This shouldn't be here!  remove it.
 #gateway 198.58.104.1

And secondly, to get rid of the annoying resolv.conf error run:

sudo dpkg-reconfigure resolvconf

Although this is a separate issue.

share|improve this answer
    
Fixed my resolv.conf issue. Edited my question, still seeing the same issue after breaking out the auto line. –  tubaguy50035 Dec 5 '12 at 22:38
    
Try a full reboot. I've not had much success with networking restart personally. It's not always cleanly restarted. Failing that, try changing eth0:1 to eth0:2 –  Matt Dec 5 '12 at 22:41
1  
Also don't change your question too much. It won't be useful if you solve it and make it right. e.g. you've now removed the resolvconf stuff. –  Matt Dec 5 '12 at 22:42
    
True. I removed it since it obviously wasn't a part of the real issue. –  tubaguy50035 Dec 5 '12 at 22:43
    
Remove the second gateway –  Matt Dec 5 '12 at 22:51
show 1 more comment

Try this command:

sudo dpkg-reconfigure resolvconf

Also this:

ifdown eth0:0 
ifdown eth0:1 
ifdown eth0
ifup eth0

The ifup eth0 at the end starts both the primary and the alias AND only sets the route once.

share|improve this answer
    
Fixed the resolv.conf issue –  tubaguy50035 Dec 5 '12 at 22:35
    
Alright, I edited my post. –  Zim3r Dec 5 '12 at 22:40
add comment

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.