LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 02-06-2003, 10:12 AM   #1
campo
LQ Newbie
 
Registered: Jan 2003
Posts: 18

Rep: Reputation: 0
hostname change


hi,

When I installed redhat 8 it seems to have assummed my windows computer identification name (I have dual boot with XP) as my hostname.

In windows my computer identification name is "BAZZA". So when I boot up to linux my hostname is "BAZZA" (eg, I get a "Welcome to BAZZA" message in the login screen.) I have tried to change this to "localhost" using the command:

[root@BAZZA root]# hostname localhost
[root@BAZZA root]# hostname
localhost

Which seems to work for the remainder of the session but when I reboot the hostname reverts to "BAZZA." Is there anyway I can permanent change the hostname back to local host?

Thanks Andy
 
Old 02-06-2003, 10:43 AM   #2
dimeo111
LQ Newbie
 
Registered: Nov 2002
Distribution: RedHat 8.0
Posts: 11

Rep: Reputation: 0
This might help you go too google an type root it should bring up an online Book which will give you an Idea on command lines or should it be shell lines any way go through the book reed it all hope it helps with your problem.
 
Old 02-06-2003, 10:47 AM   #3
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
Or, edit the file

/etc/hostname

and put in the name you want.
Can be anything.

I don't recommend using "localhost" as your name for various reasons. (People on your LAN pinging "localhost" will get their own system's 'localhost' IP, which is 127.0.0.1, and thus won't be able to ping your hostname.)
 
Old 02-06-2003, 11:13 AM   #4
peter72
Member
 
Registered: Oct 2002
Location: Charlottesville, VA
Distribution: Ubuntu (home), SLES (work)
Posts: 196
Blog Entries: 1

Rep: Reputation: 30
don't forget an entry into /etc/hosts, /etc/networks and /etc/sysconfig/network.

To check, do a %uname -u

You may not even have and /etc/hostname.

I remember solaris and DEC alphas use/etc/nodename.
 
Old 02-06-2003, 12:08 PM   #5
campo
LQ Newbie
 
Registered: Jan 2003
Posts: 18

Original Poster
Rep: Reputation: 0
My /etc/hosts already reads

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

there is no mention of BAZZA. Yet when I reboot I still login to BAZZA and have [root@BAZZA]# at the command prompt. I do not seem to have the files /etc/networks, /etc/sysconfig/network either. Any ideas? Im on Redhat 8.0

Cheers Andy
 
Old 02-06-2003, 12:23 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by campo
My /etc/hosts already reads

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

there is no mention of BAZZA. Yet when I reboot I still login to BAZZA and have [root@BAZZA]# at the command prompt. I do not seem to have the files /etc/networks, /etc/sysconfig/network either. Any ideas? Im on Redhat 8.0

Cheers Andy
Your /etc/hosts doesn't define your own systems hostname.. scroll up to Wolven's response.. and I would suggest not naming your machine localhost as well unless this is the only machine on your network.. etc.
To change by command line just type:

hostname [new-name]

Last edited by trickykid; 02-06-2003 at 12:26 PM.
 
Old 02-06-2003, 12:24 PM   #7
peter72
Member
 
Registered: Oct 2002
Location: Charlottesville, VA
Distribution: Ubuntu (home), SLES (work)
Posts: 196
Blog Entries: 1

Rep: Reputation: 30
A friend gave me what I think is the answer. It's your DHCP server. It cached your hostname and MAC address.

To fix, stop using WinXP If you are in control of you DHCP server, then you can usually clear out that cached entry. There may also be a way to override the cache, but don't know how right now. May be able to google it.

If I find a solution, I'll let you know.
 
Old 02-06-2003, 01:29 PM   #8
SlickWilly
Member
 
Registered: Dec 2002
Posts: 327

Rep: Reputation: 30
I too believe it's your DHCP.

But first.. let's be sure. Are you using DHCP?

Slick.
 
Old 02-06-2003, 03:01 PM   #9
campo
LQ Newbie
 
Registered: Jan 2003
Posts: 18

Original Poster
Rep: Reputation: 0
yeah Im running a DHCP client for my internet connection and a DHCP server for my network. Its only a two computer network connected with a cross over cable. So basically my machine runs Linux and connects to the internet and the other computer connects to my machine.

In response to wolvens post I do not have a file /etc/hostname either.
 
Old 02-06-2003, 03:41 PM   #10
SlickWilly
Member
 
Registered: Dec 2002
Posts: 327

Rep: Reputation: 30
/etc/hostname isn't anything I've ever heard about.

You should make sure you have an entry in /etc/hosts though.

But I suspect if you've never set your hostname, then DHCP is doing it for you. You might want to look in :

[edit]
Doh! Hit the wrong button... Continuing
[/edit]

/etc/sysconfig/network-scripts

There are a bunch of scripts in there which control your network connections. For the sake of completeness I'm going to go into a great deal of detail here, but the solution is fairly simple

ifup - is a script which 'ups' a network connection. It contains the following lines :

if need_hostname; then
PUMPARGS="${PUMPARGS} --lookup-hostname"
DHCPCDARGS="${DHCPCDARGS} -H"
fi

The -H on the end of DHCPCDARGS is important here. It tells dhcp to 'set the hostname of this machine to be what DHCP tells me my interface is called'.

need_hostname is defined in /etc/sysconfig/network-scripts/network-functions

it looks like this :

need_hostname()
{
if [ "`hostname`" = "(none)" -o "`hostname`" = "localhost" -o \
"`hostname`" = "localhost.localdomain" ]; then
return 0
else
return 1
fi
}

Which basically says 'if I don't have a hostname, or my hostname is localhost (or localhost.localdomain) then I need a hostname...

There are two ways you can do this. You can either manually (or in a script at bootup) type 'hostname humbert' or you can set it in

/etc/sysconfig/network

where the file should contain the following :

NETWORKING=yes
HOSTNAME='humbert'

where 'humbert' is the name of your machine. Once you set that you should be good.

Allternatively, if you don't like the way that DCHP works, you can remove the -H from the DHCP section of the 'ifup' script, and it won't ever do it again.

*bounce*

Slick.



Last edited by SlickWilly; 02-06-2003 at 03:48 PM.
 
  


Reply



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
How do you change your hostname? Thaidog Linux - Newbie 6 07-24-2005 08:52 PM
Change hostname garlam Slackware 2 10-13-2004 02:19 AM
How to change hostname blackbart Linux - Newbie 2 02-01-2004 02:56 PM
change hostname dincer80 Linux - Networking 3 07-31-2003 01:30 AM
change hostname kafnir Linux - Networking 1 10-21-2002 11:10 AM

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

All times are GMT -5. The time now is 09:07 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