LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Does my host name change due to DHCP? (https://www.linuxquestions.org/questions/linux-newbie-8/does-my-host-name-change-due-to-dhcp-508539/)

ChrisR(SQL DBA) 12-08-2006 07:59 AM

Does my host name change due to DHCP?
 
Howdy all. When I installed CentOS 4, I don't think I assigned a host name. That beign said, would my host name then be the ip address? But it gets worse....

My ip address has since changed due to dhcp. When I go into the terminal, I am connected as user@ip22-22-22-22(not really all 2's). The address is my new address, not the address I had when I originally installed the OS. So as near as I can tell, the host name was assigned the IP address, and changed when the IP changed. Is that the case?

lord-fu 12-08-2006 08:04 AM

Hi there,

A hostanme is typically ComputerName.Domain, if you assigned a computername that would be the hostname. When you are connected at a terminal is it showing your internal ip address, or are you talking about ssh from the outside?, just asking because this is what I commonly see. Not too sure about CentOS though. On my Slackware box I have /etc/HOSTNAME, do you have the same?

pixellany 12-08-2006 08:06 AM

You assign the hostname, and dhcp assigns the IP **to that name**. DHCP is not going to change your hostname.

When you do assign a hostname, don't make it like an IP--that would have the potential of really confusing the SW--not to mention the operator of the computer. Just name the computer after your favorite pet, girlfriend, etc.

ChrisR(SQL DBA) 12-08-2006 08:10 AM

Quote:

Originally Posted by lord-fu
Hi there,

A hostanme is typically ComputerName.Domain, if you assigned a computername that would be the hostname. When you are connected at a terminal is it showing your internal ip address?, just asking because this is what I commonly see. Not too sure about CentOS though.


Sorry, I should have specified this as well. When I log in/ out I see ip.domainName in the lower right corner, which is another reason I suspected it as being the host name. Regardless, I just found out that ipconfig is not universal, and was wondering if there is a way for me to determine my host name?

pixellany 12-08-2006 08:24 AM

the hostname command will do it.

On my machine, it is in a file named /etc/hostname. It also appears in /etc/hosts

To change it, I **think** you need to change both files. (But look first in the GUI network setup)

What do you mean "ipconfig is not universal"?

ChrisR(SQL DBA) 12-08-2006 08:34 AM

I mean I ran ipconfig and it said "command not found" (its a windows command).

I ran the hostname command (thanks for the tip) and it gave me back:

ip22-222-222-222.domainName.net (not really all 2's)

Is that my host name?

lord-fu 12-08-2006 08:40 AM

ifconfig is what you want.
As I said in my post and pixellany mentioned, try /etc/HOSTNAME.

pixellany 12-08-2006 08:40 AM

In Linux it is "ifconfig"

The complete hostname is name.domain but at least on my system, hostname just gives the name. Perhaps you have told your machine that "name" is really "name.domain"

Look in /etc/hosts and you will see something like this:
127.0.0.1 localhost.localdomain localhost mepis1
These are all aliases for the hostname

Please post the content of your /etc/hosts file

Again, you don't want an IP address for a hostname

ChrisR(SQL DBA) 12-08-2006 08:45 AM

Quote:

Originally Posted by lord-fu
Hi there,

On my Slackware box I have /etc/HOSTNAME, do you have the same?

Sorry, I just noticed you question. No, I have /etc/hosts, which only contains the entry:

127.0.0.1 localhost.localdomain localhost

pixellany 12-08-2006 08:48 AM

Quote:

Originally Posted by ChrisR(SQL DBA)
Sorry, I just noticed you question. No, I have /etc/hosts, which only contains the entry:

127.0.0.1 localhost.localdomain localhost

This will need to include whatever is in hostname---which, in turn, should be just one simple short word.

Did you try looking in the GUI network setup? Might be a lot easier than changing all the low-level files.

ChrisR(SQL DBA) 12-08-2006 02:27 PM

Thank you all for your efforts thus far. the only thing in my /etc/hosts file is:

127.0.0.1 localhost.localdomain localhost

Also, I found a GUI Network Config tool, and under Hostname it says "localhost.localdomain".

These two things, plus the fact that I didn't assign a name during install, is leading me to beleive the name is acutally "localhost". Is this correct?

pixellany 12-08-2006 02:52 PM

Quote:

Originally Posted by ChrisR(SQL DBA)
Thank you all for your efforts thus far. the only thing in my /etc/hosts file is:

127.0.0.1 localhost.localdomain localhost

Also, I found a GUI Network Config tool, and under Hostname it says "localhost.localdomain".

These two things, plus the fact that I didn't assign a name during install, is leading me to beleive the name is acutally "localhost". Is this correct?

I think maybe "localhost" is some kind of default. What does the command hostname say?

Actually, that command may be how you CHANGE the hostname---YES!! check man hostname for how to change your hostname at the CLI.

ChrisR(SQL DBA) 12-08-2006 04:10 PM

I changed it both using Hostname, and using the GUI, and it is for sure now named what I want.

Thanks to all!

pixellany 12-08-2006 04:19 PM

Yea!!!--we love happy endings


All times are GMT -5. The time now is 07:35 PM.