Veeam – Re-visit Linux Re-IP

I wrote a blog post back in 2013 , //www.cragdoo.co.uk/veeam-replication-linux-vm-failover/, on how to Re-IP Linux VMs. This week I have been working on the same thing , for a customer’s DR replication and I’ve come across a couple of improvements/changes that can be made to make the process a little easier.

Script Update

So the 1st thing I came across is a missing ‘|’ and some funky issue with inverted commas/apostrophes , this may have been a typo or a formatting issue with the cut and paste, so here is the updated script

#!/bin/bash
#Ping DR bounce node
ping -c 1 -tย  1 192.168.110.7 > /dev/dull;
if [ $? -eq 0 ]; then
#Ping successful so change ip address to DR network range
ifconfig eth0 172.20.2.59 netmask 255.255.255.0;
route add default gw 172.20.2.1 eth0;
else
#Cannot ping address so back in live environment change ip back if still set to DR
address= $(ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | awk '{print $1}')
if [ $address = '172.20.2.59' ]; then
ifconfig eth0 192.168.110.59 netmask 255.255.255.0;
route add default gw 192.168.110.253 eth0;
fi
fi

Linux Re-IP script - bash view

Runlevel

In the original post I hadn’t mentioned the location of rc.local , this is located in /etc/

While dealing with the customer setup, for some unknown reason I had been placing the link to the script in /etc/rc3.d , however the VM in question was using run level 2, you can check this by performing :-

cragdoo@linuxtest:~$ runlevel

N 2

cragdoo@linuxtest:~$

So placing it in /etc/rc3.d isn’t going to work ๐Ÿ™

/etc/rc.local is a better place to put the link, as it gives all the networking services a chance to start up, to allow the script to successfully ping the DR IP โ€ฆor not

A quick(ish) update post , for my own sanity rather informational ๐Ÿ™‚