SCIENTIFIC-LINUX-USERS Archives

March 2016

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Fri, 18 Mar 2016 15:59:09 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (41 lines)
On Fri, Mar 18, 2016 at 1:22 AM, Steven J. Yellin
<[log in to unmask]> wrote:
>
> To satisfy my own curiosity I looked on an SL6.7 computer for how
> hostname gets set.
>
> In /etc/init.d/network, which brings networking up and down, are lines
>
> cd /etc/sysconfig/network-scripts
> . ./network-functions
> and calls to ifup.
>
> The ifup script can invoke ifup-eth (in network-scripts), which can
> invoke ifup-post, which can do 'set_hostname $HOSTNAME', where set_hostname
> is one of the functions in the above mentioned network-functions. That
> function does 'hostname $1'. So ultimately the scripts that bring the
> network up apparently do the same thing as you would do by hand to set the
> hostname.
>
> With your current scripts I don't see how you can tell whether the init
> scripts set the hostname or a human did it. But you could save the current
> ifup-post just in case you want to restore it, and replace it with a version
> that calls net_log, also in network-functions, whenever ifup-post invokes
> set_hostname. For example, on SL6 I think it would work if just before the
> ifup-post line calling set_hostname you add a line
>
> net_log "Call set_hostname with hostname ${HOSTNAME}." info
>
> Later you can compare the resulting line in /var/log/messages to what the
> hostname currently is.

Thanks. I was surprised by the above because I thought that the
hostname was set by "/etc/rc.d/rc.sysinit" on SL6.

Looking at "/etc/sysconfig/network-scripts/network-functions" and
"/etc/sysconfig/network-scripts/ifup-post", the latter only sets the
hostname if it's "(none)", "localhost", or "localhost.localdomain" and
if "ipcalc --silent --hostname ${IPADDR}" returns a hostname (it also
depends on device, device type, and whether this is the boot
phase...).

ATOM RSS1 RSS2