Problems bringing up a second virtual network interface
Solution 1
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.
Solution 2
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.
Related videos on Youtube
nwalke
Updated on September 18, 2022Comments
-
nwalke over 1 year
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 upeth0: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
andeth0:0
.-
hookenz over 11 yearsRemove the second gateway 198.58.104.1
-
nwalke over 11 yearsFor future readers, I did still have to reboot even after I removed the second gateway.
-
hookenz over 11 years/etc/init.d/networking restart has always been problematic for me. Always best to do a full machine reboot.
-
Arunas Bartisius over 4 yearswith current Debian based systems syntax has changed: unix.stackexchange.com/questions/427414/…
-
-
nwalke over 11 yearsFixed the resolv.conf issue
-
nwalke over 11 yearsFixed my resolv.conf issue. Edited my question, still seeing the same issue after breaking out the auto line.
-
Zim3r over 11 yearsAlright, I edited my post.
-
hookenz over 11 yearsTry 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
-
hookenz over 11 yearsAlso 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.
-
nwalke over 11 yearsTrue. I removed it since it obviously wasn't a part of the real issue.
-
hookenz over 11 yearsRemove the second gateway
-
nwalke over 11 yearsRemoved the second gateway and still couldn't get it to work. Rebooted and everything is working now.
-
SteffenNielsen about 9 yearsThe two gateways of the same physical netcard seemed to be the problem for me too. To avoid rebooting, I did: ifdown eth0:1; ifconfig eth0:1 down; ifup eth0:1. It then came up without any erros/warnings.