Read Articles

Monday, 25 October 2010

How to Change Your Linux Hostname Without Rebooting

If you’ve worked in the admin world for any length of time, you’ve probably run into an instance where you needed to change the hostnames on your server to match some corporate naming standard, but you can’t have downtime either. So how do you change the hostname without rebooting?

Changing the Hostname

First, you must change the config file that controls this. The actual file and its location will vary across distributions. In the Redhat derivatives, the file to modify is /etc/sysconfig/network so vi this file and change the line that reads HOSTNAME=
From this:
To this:
For SuSE distributions you would similarly change the /etc/HOSTNAME file while Debian admins would modify the /etc/hostname file to set the new name.
Next, the /etc/hosts file needs to be changed. This is identical across all flavors and consists of using your favorite text editor and modifying the old hostname within. Such as from this:
To this:
“But”, you mutter under your breath, “I just typed in `hostname` and got ‘Snoopy’ as a result. It doesn’t work!”.
What you need to know is that the previous steps are to permanently set the new name. You are much too quick to judge, obviously. So, continue on by entering (at the command line as root or a sudoer):
# hostname mdmvr14s9db
This will set the hostname for now but the change is not saved (that is what the above steps are for, remember?). Go ahead – test it. Type in `hostname` (without the tickmarks ) and the command should return ‘mdmvr14s9db’ (without the single quotes).
Now let’s set it in stone. If you are using chkconfig and service commands (RedHat family folk, usually), you can simply type
#service network restart
which will restart the network with the new host name. The rest of you should be able to type
#/etc/init.d/network restart
to obtain the same results.
Then test again with the hostname command – you should get the new name returned.
This has been the easy part. Hopefully, prior to starting this, you checked all application conf files for any hard coded reference to the new name and changed that as well. And you need to then change your DNS ‘A’ record to also reflect the new name. And once you have restarted named with the new name on the DNS you will have succeeded in temporarily irritating around half of those 18,000 users previously mentioned who now can’t get to the server since the name has not propagated around the network yet. But this too shall pass as long as you hide long enough.
And at least you can keep the small stuffed plush Snoopy sitting at your desk to remind you of that gentler, simpler time.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

free counters

Categories

Blog File Sharing Troubleshooting all Computer Troubleshooting How to Operating System Internet Maintanance and Repair ERROR Solutions Help Support Help and Support Device Manager Error Computer Windows Device Applications Install Java Script Computer Repair Java Programe Photoshop Add HTML facebook on site Computer Management Facebook and Site Messenger and Chat Protect Your Computer XFBML and HTML Facebook BELAJAR PHOTOSHOP Shortcut Startup Programs TUTORIAL PHOTOSHOP Windows Administration Tools Create DVD Create DVD Maker Keyboard Network Set Up Security Security System Test DVD Test DVD Drive VGA Card VGA Conector VGA Informations CA-CLIPPER INTERNAL ERROR Crack Create PDF Create PDF using Smart PDF Creator Error windows explorer Hard Drive Partitioning Intall Windows 7 Ultimates Internet Browser Local Area Network Networking PDF EDITOR Protect CD from Copy Router Smart PDF Creator Tutorial Java USB REMOVE Word Password Remover Access Media Collection Adsense Animator Anomymity Computer Hang Computer Icon Computer Set Up D-Link D-Link Router DNS DVD Drive DVD compress Device Drive partitions Drive parts Earn Money Easy Gif Animator Elastomer Eror Solution External Hard Drive Facebook Free Internet Hack Password Hard Drive How to Download Inside Adsense Internet Explore JPEG JPG GIF PNG BMP Laptop Laptop vs PC MS Word to PDF Make DVD Make Money with blog Make Your Own Copy-Protected CD with Passive Protection Modem Ms Word Applications Online Shoping PC Desktop PDF Remover Partitions drive Picture Prevent Windows XP Print Printer Error Reboot Application Remove Pasword Excel Restore Windows Registry Search Engines Optimizer Social Networking Solving Probelm System Registry Upload File to blogger Upload Files Virtual Memory is to Low Viture Windows 7 Windows DVD Maker Wireless Wireless router Words error intall windows explorer cannot open words documents cannot open

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More