Re: Behavioral change in hostname

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

 



On Tue, Sep 22, 2009 at 08:40:51AM -0400, Tom Horsley wrote:
> On Tue, 22 Sep 2009 08:31:09 -0400
> Robert Moskowitz wrote:
> 
> > What can be done to get 'hostname' to always figure out to return the 
> > FQDN if one exists?
> 
> I always thought it returned whatever was set as HOSTNAME=
> in the /etc/sysconfig/network file.

Not exactly.  Here is a code used by a network configuration

    if need_hostname; then
        IPADDR=$(LANG=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }')
        eval $(/bin/ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
        if [ "$status" = "0" ]; then
            set_hostname $HOSTNAME
        fi
    fi

where need_hostname function looks like that:

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
}

So if you are assigning addresses to interfaces dynamically and
ipcalc can get hostname like the above then names will correspond to
addresses.  There is a bit more of "sanity checks" elsewhere but
these are main parts.

Last time I tried NetworkManager was incapable of doing things of
that sort so you had to use 'network' service to get such effects.

   Michal

-- 
fedora-test-list mailing list
fedora-test-list@xxxxxxxxxx
To unsubscribe: 
https://www.redhat.com/mailman/listinfo/fedora-test-list

[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux