The FreeBSD Diary |
(TM) | Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link. |
Managing an IP address change - part 2
4 October 2002
|
It was almost a month ago that I started changing the IP address of The FreeBSD Diary web server. When I first mentioned to someone that I was going to write an article about this process, they wondered: why, all it takes is an ifconfig, what is there to write about? I guess they didn't understand the whole story. Yes, if you're changing the IP address of a box which is not providing services, then no, it's not much of a big deal. Please read Part 1 of this article. |
DNS propagation
|
The key point to consider when changing an IP address is DNS. By its very nature, DNS information is distributed. That is part of how it works so well. If someone looks up the IP address for www.freebsddiary.org, they will store that answer for a while. That reduces network traffic, reduces the load on my DNS servers, and makes things faster at their computer (they don't have to wait for each DNS query to complete; only the first one). It follows that the downside to this efficiency comes when the information must change. It takes time for this information to propagate. How much time depends upon your settings within your domain's zone files. Look at the Expire and Refresh values to see just how long it can take. It appears that these values are not strictly honored by all DNS servers. Some like to cache longer than the domain settings. That's their problem and there's nothing you can do about that. The box in question (m20.unixathome.org) has several functions, which include:
|
Other IP addresses to change
|
I had other domains which pointed at m20. I wanted to update their DNS as well. Those changes simply involved modifying the IP address, as opposed to adding a second value to the existing host names. These were easy to do. After those changing had propagated, I was then ready to remove the old IP address from m20. |
Swapping primary & alias on ifconfig - failure
|
On Monday, I decided it was time to go one step further in the process. I wanted to swap the primary and alias IP addresses. Although a NIC may have more than one IP address, by default, all outgoing connections will originate from the primary IP address and not the alias. This will have effects on the outside world as my box attempts to send out information. Namely, it will affect firewalls which [should] filter by IP address.
To effect these changes, I went ahead and modified In hindsight, the messages on the console showed that routing was a problem. Here's what I was seeing which led me to believe that:
I guessed that routing was a problem. Then I remembered that I had not changed the default route (i.e.
the defaultrouter entry in /etc/rc.conf ).
I wasn't 100% positive that this was the only problem, but it looked like a starting point.
|
Swapping primary & alias on ifconfig - success
|
It wasn't until Friday October 3 that I was ready to try again. This time I had a cunning plan. I had decided to change the IP addresses via the command line rather than risk a reboot. But this had to be done carefully. There was the risk that removing the IP address would terminate the ssh session. And then where would I be? The plan involved two cron jobs: one to change the IP address, and another to reboot the box in case the change locked me out. A cunning plan indeed. Here is the shell script:
Yes, those are the real IP addresses.
And here are the cron jobs:
As you can see, at 36 past the hour, the IP addresses would change and so would the default gateway. That gave me four minutes to confirm everything was healthy before the system automagically rebooted. After the shell script ran, I checked the NIC details:
Hmmm, well that certainly seems to have worked. I ran a few other tests (e.g. made sure I could create a new ssh session to
the computer, and that I could run cvsup on the box and update the website).
Don't forget to disable those cron jobs! |
Final /etc/rc.conf changes
|
The ultimate goal in swapping primary and alias IP addresses was to make it easier to remove the old IP address. That will
be done later using an |
I'm not finished yet
|
There are still a few things left to do:
|