Friday, March 1, 2013

IP Switching Procedure

The steps to be followed to switch the main IP of a server to another server.

If IP switch is from deidcated server to deidcated, follow below


Suppose that we are having an old server with IP 72.34.41.200(Gateway-72.34.41.129 Netmask-255.255.255.128) and a new server with IP 72.34.40.195 (Gateway-72.34.40.129 Netmask-255.255.255.128).In order to switch the IP 72.34.41.200 from the old server to the new server, we will have to move the IP of new server, 72.34.40.195 to the old first. We will have to connect KVM to the new server since we will not be able to connect to the server when the main IP of the server is down.

Since IPs are on the same rack and uses the same gateway, you can try the easy and fast method.
Interchange the IPADDR values of the file /etc/sysconfig/network-scripts/ifcfg-eth0 of two servers and reboot the machines together. When the server is up, IPs will be interchanged. One thing to note here is that, if the grub.conf had got the IP being passed to the default kernel, then you should edit the default kernel entry.

Eg:
title CentOS (2.6.35.13-24)
root (hd0,0)
kernel /vmlinuz-2.6.35.13-24 ro root=LABEL=/ netconsole=10000@72.34.47.10/eth0,514@216.193.213.40/00:21:a0:63:38:3f ndev=eth0,00:e0:81:31:56:2e realip=72.34.47.10/24,eth0,72.34.47.1,0

Edit it like
title CentOS (2.6.35.13-24)
root (hd0,0)
kernel /vmlinuz-2.6.35.13-24 ro root=LABEL=/

If the above did not work, follow the below method.
1. Login to the KVM of the new server.
2. Run the following command to take the main IP of new server down.
ifdown eth0

3. Now login to the old server with IP 72.34.41.200 and edit the files /etc/sysconfig/network-scripts/ifcfg-eth0 with the IP address changed to IPADDR=72.34.40.195. Also add the gateway as GATEWAY=72.34.40.129. So the file

/etc/sysconfig/network-scripts/ifcfg-eth0 will contain the following:
DEVICE=eth0
BOOTPROTO=static
IPADDR=72.34.40.195
NETMASK=255.255.255.128
GATEWAY=72.34.40.129
ONBOOT=yes
TYPE=Ethernet

4. Edit the file /etc/sysconfig/network in the old server to change the gateway as GATEWAY=72.34.40.129

5. Restart the network using the command
/etc/init.d/network restart

By restarting the network, the IP 72.34.41.200 will be down in the old server and the IP 72.34.40.195 will be up.

6. Now you have to up the IP 72.34.41.200 in the new server using KVM. Edit the file /etc/sysconfig/network-scripts/ifcfg-eth0 with the IPADDR and GATEWAY set to 72.34.41.200 and 72.34.41.129. And the file
/etc/sysconfig/network with the GATEWAY.

7. Run the command
ifup eth0

8. Restart the network
/etc/init.d/network restart

9. Now in the new server, 72.34.41.200 is the main IP and in the old server 72.34.40.195 is the main IP. Now we have to run the "arping" command to update the MAC address associated with the IP.
arping -I eth0 72.34.41.200

By this the IP will start to ping from the new server.
Now in order to switch the private IP address from one server to another, down the IP in the old server by running the command:

ifdown eth1

In the new server, add the IP address in /etc/sysconfig/network-scripts/ifcfg-eth1 and restart network
/etc/init.d/network restart

A router needs to be set for the private network. Run the following command:
ip route add 10.10.0.0/16 via 10.10.10.1 dev eth1

ifconfig will show the IP address and make sure that it is pinging from the server.

No comments:

Post a Comment