LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2002, 01:53 AM   #1
Silly22
LQ Newbie
 
Registered: Mar 2002
Location: Edmonton, AB
Distribution: Mandrake 10.2, Ubuntu 6.10
Posts: 26

Rep: Reputation: 15
Question 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.
 
Old 03-28-2002, 12:44 PM   #2
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 31
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
 
1 members found this post helpful.
Old 03-29-2002, 05:01 PM   #3
Sixpax
Member
 
Registered: Mar 2002
Distribution: Mandrake 8.1
Posts: 386

Rep: Reputation: 31
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
socks proxy - env variable andrewlkho Linux - Networking 1 06-23-2013 09:58 PM
Running a shell script remotely via 'ssh <hostname> <command>' davee Linux - General 4 10-09-2005 01:38 AM
env variable for proxy: syntax FrayAdjacent Linux - Networking 10 07-13-2005 05:44 PM
env variable allelopath Linux - Software 3 04-14-2005 12:07 PM
Can someone tell me a command to determine the hostname of an IP on the network? brow27 Linux - Newbie 4 05-20-2004 03:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration