I've been looking for this for the last 8 hours, nobody seems to have an answer anywhere, and I'm starting to lose my sanity.
note: Network manager is not installed
Sorry if this has already been answered, I didn't find it.
Short story : What is the syntax to use in /etc/network/interfaces to bind several virtual IP's to eth0 that are not in the same network than eth0's main IP ?
Long story : I'm probably stupidly wrong, but it may also be a bug, hence the verbosity
I'm migrating an old web server on Ubuntu to a new server in a xen virtual machine running on Wheezy. (From OVH, a big hosting company, no physical access to the servers)
On the old server, I had several ip adresses FROM DIFFERENT NETWORKS on the same interface.
It worked with the following good old syntax in /etc/network/interfaces (I changed the ip adresses)
Code: Select all
auto eth0
iface eth0 inet static
address 95.125.209.64
netmask 255.255.255.0
network 95.125.209.0
broadcast 95.125.209.255
gateway 95.125.209.254
auto eth0:0
iface eth0:0 inet static
...
auto eth0:1
iface eth0:1 inet static
address 84.96.133.38
netmask 255.255.255.0
network 84.96.133.0
broadcast 84.96.133.255
gateway 84.96.133.254
Code: Select all
root@xxx:/# /etc/init.d/networking stop && /etc/init.d/networking start
[....] Deconfiguring network interfaces...RTNETLINK answers: No such process
done.
[....] Configuring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0:1.
done.
root@xxx:/# cat /etc/network/run/ifstate
lo=lo
eth0=eth0
root@xxx:/# ifconfig -a
eth0 Link encap:Ethernet HWaddr ...
eth0:1 Link encap:Ethernet HWaddr 4c:72:b9:7b:b3:4d
inet addr:84.96.133.38 Bcast:84.96.133.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:20 Memory:fe500000-fe520000
lo Link encap:Local Loopback ...
and when I ping eth0:1 adress (84.96.133.38), it works.
I read somewhere that ifconfig is to be replaced by ip.
So, I try with this /etc/network/interfaces :
Code: Select all
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 6.134.187.173
netmask 255.255.255.0
network 6.134.187.0
broadcast 6.134.187.255
gateway 6.134.187.254
up ip addr add 84.96.133.38/24 dev eth0 label eth0:1
down ip addr del 84.96.133.38/24 dev eth0 label eth0:1
iface eth0 inet6 static ...
Code: Select all
root@xxx:~# /etc/init.d/networking stop && /etc/init.d/networking start
[....] Deconfiguring network interfaces...RTNETLINK answers: No such process
done.
[ ok ] Configuring network interfaces...done.
I try to add this
Code: Select all
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 6.134.187.173
netmask 255.255.255.0
network 6.134.187.0
broadcast 6.134.187.255
gateway 6.134.187.254
up ip addr add 84.96.133.38/24 dev eth0 label eth0:1
down ip addr del 84.96.133.38/24 dev eth0 label eth0:1
up route add -net 87.98.133.0 netmask 255.255.255.0 gw 87.98.133.254 dev eth0:1
down route del -net 87.98.133.0 netmask 255.255.255.0 gw 87.98.133.254 dev eth0:1
iface eth0 inet6 static ...
Code: Select all
root@xxx:~# /etc/init.d/networking stop && /etc/init.d/networking start
[....] Deconfiguring network interfaces...SIOCDELRT: No such device
done.
[....] Configuring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
RTNETLINK answers: File exists
Failed to bring up eth0.
done.
root@xxx:~# cat /etc/network/run/ifstate
lo=lo
Let's rollback
Code: Select all
auto eth0
allow-hotplug eth0
iface eth0 inet static
...
#up ip addr add 87.98.133.38/24 dev eth0 label eth0:1
#down ip addr del 87.98.133.38/24 dev eth0 label eth0:1
#up route add -net 87.98.133.0 netmask 255.255.255.0 gw 87.98.133.254 dev eth0:1
#down route del -net 87.98.133.0 netmask 255.255.255.0 gw 87.98.133.254 dev eth0:1
Code: Select all
root@xxx:~# /etc/init.d/networking stop && /etc/init.d/networking start
[ ok ] Deconfiguring network interfaces...done.
[....] Configuring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
RTNETLINK answers: File exists
Failed to bring up eth0.
done.
Is that a bug ? Does the network script read its configuration from elsewhere ?
Is there a cleaner way to do it ?