Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a way of doing this, but not sure if its the best.

I have two servers, we'll call Server-old, and Server-new. both are running different versions of CentOS. (5.0, and 5.7) Both are also on different IP's in the same subnet, but other wise are running the same software, firewall rules, and configs. I am switching from Xen to VMWare for this host, and its easier to just build a new server..

Server-old gets lots and lots of traffic, both via static NAT routes, and direct to its ip (via other servers connected to the vpn)

To make things smoothly move over (since not everyone uses the DNS name) I need to swap the IP Addresses as quickly as possible, in the middle of the night when traffic is slower.

I am planning on editing both servers /etc/sysconfig/network-scripts/ifcfg-eth0 files and put their 'new' addresses in, opening up two ssh sessions:

  • Server-Old type in ifdown eth0; sleep 10; ifup eth0
  • Server-new type in ifdown eth0;ifup eth0

and then hit enter on the Server-old, then as fast as I can, hit enter on Server-new

I'm thinking this is about the fastest I can switch, without causing any IP address conflicts. Or is there a better way to swap them?

share|improve this question
    
I'd add virtual interface eth0:0 on Server-new poiting to the Server-Old IP address and then shut down interface on Server-old. –  Dmitry Alexeyev Sep 20 '11 at 19:22

3 Answers 3

up vote 0 down vote accepted

This is the fastest way if nothing comes in between. So my favorite would be to do it from a real console. It's bad when the network is down and you can't connect via ssh.

share|improve this answer
    
or if you have setup a HP ILO network or Dell DRAC..then it can be managed remotely.. –  krisdigitx Sep 20 '11 at 17:02
    
...yes and if it is virtual you can use the hypervisor-console. But you can't beat real hardware access –  mailq Sep 20 '11 at 17:04
    
good point.. I have console access via both the xen host and the vmware host.. thanks! –  Brian Sep 20 '11 at 17:06

Make sure that that time on both servers is the same, set up a cron job to fire off at 2:00am (or whatever 'middle of the night' time you choose), and have it run:

service network restart

then delete the cron job the next morning, or after it runs.

share|improve this answer
    
This is good, as you don't have to worry about the commands getting run. You can be (reasonably) assured both systems will change their settings. –  Jason Taylor Sep 20 '11 at 17:43
    
You can use at rather than a cron job for one-off executions. –  ceejayoz Sep 20 '11 at 18:28

...more important than doing the OS-level IP plumbing quickly, you must also update the ARP protocol caches on all the devices on the LAN. If these two servers get most of their trafffic from, say, one outer-edge router, you can just blow the arp cache right after you re-plumb the IPs addrs. Packets (I'm presuming ethernet lan) flow around your LAN via ethernet addresses (which target the physical NICs on the wires), if you just replumb the IP addrs, your router and other devices will continue addressing packets to the wrong NICs for some period of time. (How long depends on how their ARP cache works.)

Also, some IP stacks won't let you plumb an IP address that already successfully RARP's (reverse ARP) on the LAN. So the cron automagic "network restart" suggestion is (in my opinion) likely to fail. When one box does the 'add' it may see the other box respond to the RARP. Meanwhile, the other box's cron job gets around to taking the IP out... train wreck.

Do it all by hand, from the consoles (bonus if you have a remotely accessible console server) it won't take but a few minutes.

If you're totally swapping the boxes, I'd also play ethernet plug shuffle... preconfigure the new one cabled into a switch (so the link is up) with nothing else on that tiny LAN. Then yank the ethernet plug from the old server, move the new server to the real LAN fabric, then blow ARP caches.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.