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.

In our computing environment we have a number of virtual machines running Red Hat Enterprise Liunx 6 that need to set their hostname programmaticly when they boot for the first time. Currently they are being set to names along the lines of ip-127-0-0-1. Which scripts do I need to update to have the hostname be set correctly based upon the DNS a boot time?

share|improve this question

2 Answers 2

How are the systems being deployed? If coming from a cloned VM, there should be some form of guest customization. If from a kickstart deployment, you can script the hostname at that level.

You could also look at your DNS and DHCP servers... I'm assuming these ip-* names are being pulled from somewhere.

In Red Hat, you can take advantage of the firstboot framework, but honestly, I handle this with Kickstart.

share|improve this answer
    
They are being deployed up to Amazon Web Services from Xen disk images. Looks like the ip-* names are the default from RHEL6. We have start up scripts for our other distros that do this but RHEL6 seems to be hiding them. :) –  rob Apr 11 '13 at 16:13
    
You can possibly use firstboot... but you'd have to try it with your build process. –  ewwhite Apr 11 '13 at 16:26

You can use ifconfig/ip addr to get the IP address, then use the host command to get the DNS hostname of the machine. You can then set the machine's hostname temporarily with the hostname command, and set it permanently by adding/editing HOSTNAME=[DNSNAME] to /etc/sysconfig/network

share|improve this answer
    
Sorry, but I already know all of that. I'm looking for a way of scripting it so that it is all done automatically when the machine boots. It looked like ifup-boot would do it, but it doesn't appear to work that way. –  rob Apr 11 '13 at 16:00

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.