Re: Hostname and IP address during kickstart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On July 14, 2004 09:30 am, Ryan Golhar wrote:
> I have a bunch of machines that I kickstart.  They all use DHCP to
> obtain their hostname and IP address.  The names are address are all
> static (in dhcpd.conf).
>
> Currently, in /etc/hosts on these machines, their hostname is set to
> 127.0.0.1 and this interferes with PVM.  I need to set their host name
> to their correct IP address in /etc/hosts.  What is the easiest way of
> doing this during %post in kickstart?
>
> Ryan


Hi Ryan,
Here is a little shell script that will overwrite the existing /etc/hosts file 
with the new IP/hostname (as well as 127...). I have tested it in a dummy 
file. It needs to be run as root.

If you have static entries, you need to add them into the script or you will 
lose them.


#!/bin/bash
# this ONLY WORKS IF there are no other entries in hosts!!
# it will overwrite anything in the hosts file!

HOSTS="/etc/hosts"
TEMP_HOSTS="/tmp/hosts.tmp"
NIC="eth0"
IP="`ifconfig $NIC | grep inet | cut -d : -f 2 | cut -d \  -f 1`"
FULL_NAME="`uname -n`"
SHORT_NAME="`uname -n|cut -d. -f1`"

echo "127.0.0.1 localhost.localdomain   localhost" > $TEMP_HOSTS
echo "$IP       $FULL_NAME      $SHORT_NAME" >> $TEMP_HOSTS
# add more static entries if needed like this:
#echo "xxx.xxx.xxx.xxx	somehost.domain.com	somehost" >> $TEMP_HOSTS

cat $TEMP_HOSTS > $HOSTS
#end

Hope that helps
-- 
Pete Nesbitt, rhce


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux