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

Categories

Access Media Collection Add HTML facebook on site addurl Administration Tools Adsense All Cat Anatomy Virus Android Animator Anomymity Anti Virus Applications Install BELAJAR PHOTOSHOP Blog Blufftop CA-CLIPPER INTERNAL ERROR cara cari uang dari internet cari uang dari internet cashfiesta Celebs Computer Desk Computer Hang Computer Icon Computer Management Computer Repair Computer Set Up Computer Tablet Computer Touch Screen Computer Troubleshooting Cookies Cookies Definitions Crack Create DVD Create DVD Maker Create PDF Create PDF using Smart PDF Creator D-Link D-Link Router Definitions of Virus Device Device Manager DNS Doc Protect Dongle USB Drive partitions Drive parts Driver Printer HP DVD compress DVD Drive Earn Money Easy Gif Animator Elastomer Eror Solution Error Computer ERROR Solutions Error windows explorer External Hard Drive Facebook Facebook and Site File Sharing Football Game Free Articles Free Internet GAME Game Sport Googel Google Talk Hack Password Hard Drive Hard Drive Partitioning Healty Help and Support Help Support Household Aplieance How to How to Download HP Lapotop Reviews IM Google Inside Adsense intall Intall Windows 7 Ultimates Internet Internet Browser Internet Explore Ipad Java Programe Java Script JPEG JPG GIF PNG BMP Keyboard Keygen Smadav 8.7 Laptop Laptop Computer Skin Laptop vs PC Life Style Local Area Network Maintanance and Repair Make CD iso Make DVD Make money online Make Money with blog Make Your Own Copy-Protected CD with Passive Protection Messenger and Chat Microsoft Mobile Aplications Mobile Phone Modem MotorSport MOVIE Ms Word Applications MS Word to PDF Ms Words My Computer Network Set Up Networking Office Online Shoping Operating System Partitions drive Password Wifi PC Desktop PDF EDITOR PDF Remover Photoshop Picture Portable Prevent Windows XP Print Printer Error Protect CD from Copy Protect Your Computer Reboot Application Remove Pasword Excel Restore Windows Registry Router Search Engine Index Search Engines Optimizer Security Security System Shortcut Smadav 8.7 Smart PDF Creator Social Networking Software software Protection Solving Probelm Startup Programs SuperBike System Registry System Restore Table Manager Test DVD Test DVD Drive Troubleshooting all Tutorial Tutorial Java TUTORIAL PHOTOSHOP uang gratis dari cashfiesta uang gratis dari internet Upload File to blogger Upload Files USB Install USB REMOVE USB Repair VGA Card VGA Conector VGA Informations Virtual Memory is to Low Virus Viture Windows 7 Watermark What is Cookies Wifi Wifi Pasword Finder Win Pes2011 Windows Windows Device Windows DVD Maker windows explorer cannot open Windows Mobile Wireless Wireless router Word Password Remover words documents cannot open Words error XFBML and HTML Facebook