hostname command vs. $HOSTNAME env. variable
Anyone have an explanation?
Why is it when I type "hostname (aNewName)" the $HOSTNAME environment variable doesn't change as well?
The change is only reflected if i type "uname -a"
I ask this because when linux boots up, ifup runs the function, need_hostname from the file, /etc/sysconfig/network-scripts/network-functions, and i believe it uses the shell command hostname to determine if it needs to set a variable called $NEEDHOSTNAME to 'yes' or to non-existent.
Then, the ifup script uses $NEEDHOSTNAME to determine if it should use the -H option when running dhcpcd.
The -H option is different from the -h option. -H sets my machine's $HOSTNAME and the value returned from typing hostname to one supplied by my ISP's dhcp server.
Anyway, my machine was previously able to boot up, obtain an IP from my ISP's dhcp server and not change my $HOSTNAME or the value returned from typing hostname. I think the value returned from typing "hostname" has something to do with it. It may have prevented ifup from using the -H option when executing dhcpcd.
I'd like to be able to boot and obtain an IP without changing my hostname. I know I can do this by commenting out the section in ifup that has the -H option when executing dhcpcd. But i'd like to avoid editing these original scripts.
I'm not sure what you're asking, but I believe that $HOSTNAME is the set by the HOSTNAME variable in /etc/sysconfig/network .
If you do not have that variable you can add it to whatever you want
HOSTNAME=some_name . If that doesn't work, try setting the DHCP_HOSTNAME variable in that same file
You can also try putting your hostname in the /etc/hostname file
The $HOSTNAME variable gets set each time you login... any changes to the actual hostname of the machine after you login won't be reflected by that variable.
I believe what you need to do is specify a hostname for your machine in /etc/sysconfig/network.
|All times are GMT -5. The time now is 11:06 AM.|