Thursday Apr 26, 2012

Hostname OEL

I noticed an odd thing when using OEL under VirtualBox.  When using bridged network, if my dhcp server supported it, I would be assigned a hostname and on booting the VM, the hostname would be updated automatically.  I really don't want this behaviour because things like the Oracle DB use the hostname for configuration file directories and some Fusion products have problems when the hostname keeps changing, especially when the hostname is not properly configured in the /etc/hosts file.

Naturally, I thought the fix would be simple.  I went into the network config, unchecked the 'Automatically obtain DNS information from provider box and put localhost.localdomain in the hostname box:


To my surprise, this didn't work.  After much playing around with the settings, I found that if I used anything but localhost or localhost.localdomain in the hostname field, it worked.  Odd.

You have to love OEL...  In the /etc/sysconfig/network-scripts directory, you'll find a file called network-functions.  There is a function called need_hostname() about halfway down the file.  You'd think the "need_hostname" would return false if the hostname field was manually set, but no...  It has this bit of code:

need_hostname ()
{
    CHECK_HOSTNAME=`hostname`
    if [ "$CHECK_HOSTNAME" = "(none)" -o "$CHECK_HOSTNAME" = "localhost" -o \
        "$CHECK_HOSTNAME" = "localhost.localdomain" ]; then
        return 0
    else
        return 1
    fi
}

As you can see, it simply checks to see if the hostname is currently localhost or localhost.localdomain.  If so, it asks for a hostname from the DHCP server.

I couldn't think of a better solution than just modifying the code.  I just hope I remember after an OS upgrade!

New code:

need_hostname ()
{
    CHECK_HOSTNAME=`hostname`
    if [ "$CHECK_HOSTNAME" = "(none)" ]; then
        return 0
    else
        return 1
    fi
}


About

me

Search

Categories
Archives
« April 2012 »
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
27
28
29
30
     
       
Today