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?
Asked
Active
Viewed 120 times
0

anonymous
- 267
- 8
- 17
2 Answers
0
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.

ewwhite
- 197,159
- 92
- 443
- 809
-
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. :) – anonymous 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
-1
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

vicfn
- 346
- 1
- 7
-
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. – anonymous Apr 11 '13 at 16:00