Child pages
  • Moving linux host between networks
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

When you need to migrate a linux VM from one network to another, you should configure proper routing so that during transition, when the host is dual homed, traffic goes out via the right interface.

Suppose your VM sits in network A, and has this configuration:

iface eth0 inet static
    address 192.87.38.10
    netmask 255.255.255.192
    gateway 192.87.38.1

iface eth0 inet6 static
    address 2001:610:148:cafe::10
    netmask 64
    gateway 2001:610:148:cafe::1 dev eth0
    pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/autoconf

Now you want to move it to network B, so that its configuration in the end would look like:

iface eth0 inet static
    address 192.87.30.10
    netmask 255.255.255.192
    gateway 192.87.30.1

iface eth0 inet6 static
    address 2001:610:148:dead::10
    netmask 64
    gateway 2001:610:148:dead::1 dev eth0
    pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/autoconf

To transition, add another network interface to the VM, and make that use the same network as the old interface.
Install the iproute package and add a new entry to the tables:

echo "1 temp" >> /etc/iproute2/rt_tables

Then configure the interfaces like this:

iface eth0 inet static
    address 192.87.30.10
    netmask 255.255.255.192
    gateway 192.87.30.1

iface eth0 inet6 static
    address 2001:610:148:dead::10
    netmask 64
    gateway 2001:610:148:dead::1 dev eth0
    pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/autoconf

auto eth1
iface eth1 inet static
   address 192.87.38.10
   netmask 255.255.255.0
   up ip route add 192.87.38.0/24 dev eth1 src 192.87.38.10 table temp
   up ip route add default via 192.87.38.1 dev eth1 table temp
   up ip rule add from 192.87.38.10/32 table temp
   up ip rule add to 192.87.38.10/32 table temp

iface eth1 inet6 static
   address 2001:610:148:cafe::10
   netmask 64
   gateway 2001:610:148:cafe::1 dev eth1
   pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/autoconf
   up ip -6 route add 2001:610:148:cafe::/64 dev eth1 src 2001:610:148::cafe::10 table temp
   up ip -6 route add default via 2001:610:148:cafe::1 dev eth1 table temp
   up ip -6 rule add from 2001:610:148:cafe::10/128 table temp
   up ip -6 rule add to 2001:610:148:cafe::10/128 table temp

If this is in place, test if you can reach the system from remote on both addresses.
If that also works, change DNS to point to the new addresses.

After DNS has propagated and there is no traffic on the old interface any more,

  • No labels