Redhat 8 incorrectly sets hostname

Redhat 8 incorrectly sets hostname

Post by Russell Reaga » Fri, 13 Dec 2002 14:17:35



When I login, I am greeted with 'Welcome to x1-6-00-10-b5-6b-0d-53'. My

warns that it cannot resolve the hostname x1-6-00-10-b5-6b-0d-53 and may
cause some things to work incorrectly. echo $HOSTNAME and /bin/hostname
both report the same string ("x1-6...").

My efforts so far have resulted in me creating a small script (see
below) to pull my ip address out of the output from ifconfig. I'm not
sure if this is a viable solution, and if it is, I don't know how to
convert the ip address to a hostname, and I also don't know where to set
my hostname with this script during the bootup. I located multiple
scripts in /etc that have the line HOSTNAME=`hostname` in it, but I
wouldn't know which one to replace it in. Also, a better method would
seem to be to set the hostname returned from my script via the hostname
command, and let it report the changed hostname.

#!/bin/sh
/sbin/ifconfig |
         grep 'inet addr:' |
         grep -v '127.0.0.1' |
         awk '{print $2}' |
         awk -F: '{print $2}'

I would like for my machine's hostname to be correctly identified, in
the correct way if possible (I'm not sure my script workaround isn't
going to cause problems elsewhere).

I'm running Redhat 8 on a dual P3 733, 512 MB RAM, with a cable internet
connection shared by 4 computers through a hub (all different IP's).

Russell

 
 
 

Redhat 8 incorrectly sets hostname

Post by Davi » Fri, 13 Dec 2002 17:11:19



> When I login, I am greeted with 'Welcome to x1-6-00-10-b5-6b-0d-53'. My

> warns that it cannot resolve the hostname x1-6-00-10-b5-6b-0d-53 and may
> cause some things to work incorrectly. echo $HOSTNAME and /bin/hostname
> both report the same string ("x1-6...").

> My efforts so far have resulted in me creating a small script (see
> below) to pull my ip address out of the output from ifconfig. I'm not
> sure if this is a viable solution, and if it is, I don't know how to
> convert the ip address to a hostname, and I also don't know where to set
> my hostname with this script during the bootup. I located multiple
> scripts in /etc that have the line HOSTNAME=`hostname` in it, but I
> wouldn't know which one to replace it in. Also, a better method would
> seem to be to set the hostname returned from my script via the hostname
> command, and let it report the changed hostname.

-- snip --

> I would like for my machine's hostname to be correctly identified, in
> the correct way if possible (I'm not sure my script workaround isn't
> going to cause problems elsewhere).

> I'm running Redhat 8 on a dual P3 733, 512 MB RAM, with a cable internet
> connection shared by 4 computers through a hub (all different IP's).

This will get your IP address but not your hostname.

/sbin/ifconfig eth0 | grep "inet addr:" |  \
awk -F: {'print $2'} | cut -d\  -f 1

The hostname is set in  /etc/sysconfig/network  unless redhat has
changed it in 8.0
If that is a hostname provided by your ISP then you can get the
hostname by using "host" something like this though you may need to
change the 48-90 to get all of the right letters for the hostname
the ISP issues.

  host `/sbin/ifconfig eth0 | grep "inet addr:" |  \
awk -F: {'print $2'} | cut -d\  -f 1` | cut -c 48-90

Hope this helps.
--
   Confucius:  He who play in root, eventually kill tree.
Registered with the Linux Counter.  http://counter.li.org

 
 
 

Redhat 8 incorrectly sets hostname

Post by Russell Reaga » Fri, 13 Dec 2002 17:50:00



> This will get your IP address but not your hostname.

> /sbin/ifconfig eth0 | grep "inet addr:" |  \
> awk -F: {'print $2'} | cut -d\  -f 1

I added in an extra grep (or a head -1 would work also) because that
reports back 127.0.0.1 also.

Quote:> The hostname is set in  /etc/sysconfig/network  unless redhat has
> changed it in 8.0

I tried a few things. It looks like it isn't set in
/etc/sysconfig/network anymore, but there are several other
possibilities where HOSTNAME=`hostname` is called


NETWORKING=yes
HOSTNAME=localhost.localdomain

profile:HOSTNAME=`/bin/hostname`
rc.d/rc.sysinit:HOSTNAME=`/bin/hostname`
rc.d/rc.sysinit:    HOSTNAME=localhost
rc.sysinit:HOSTNAME=`/bin/hostname`
rc.sysinit:    HOSTNAME=localhost
sysconfig/network-scripts/network-functions:    CHECK_HOSTNAME=`hostname`
sysconfig/network:HOSTNAME=localhost.localdomain

The files of note are /etc/profile, /etc/rc.d/rc.sysinit, and
/etc/rc.sysinit. Would it be better to change it in all of these files,
or would it be better to change it via the hostname command in the
initialization scripts BEFORE these things get called? I'll need a
little more guidance on that, since I don't know what gets called when
during start up.

Quote:> If that is a hostname provided by your ISP then you can get the hostname
> by using "host" something like this though you may need to change the
> 48-90 to get all of the right letters for the hostname the ISP issues.

>  host `/sbin/ifconfig eth0 | grep "inet addr:" |  \
> awk -F: {'print $2'} | cut -d\  -f 1` | cut -c 48-90

> Hope this helps.

host works, thanks.
 
 
 

Redhat 8 incorrectly sets hostname

Post by Paul Lutu » Fri, 13 Dec 2002 18:07:08



> When I login, I am greeted with 'Welcome to x1-6-00-10-b5-6b-0d-53'. My

> warns that it cannot resolve the hostname x1-6-00-10-b5-6b-0d-53 and may
> cause some things to work incorrectly. echo $HOSTNAME and /bin/hostname
> both report the same string ("x1-6...").

1. What hostname do you want?

2. Type it into this:

# hostname (name)

Done, forever and for all time, amen.

Quote:> My efforts so far have resulted in me creating a small script (see
> below) to pull my ip address out of the output from ifconfig.

What? That is not your host name. Just choose a name, and enter it into
"hostname". That is why "hostname" exists. It is how you change your ...
host name.

If you are not on a LAN, this should finish the job. If you are on a LAN,
put the hostname you chose into /etc/hosts along with your local IP.

--
Paul Lutus
http://www.arachnoid.com

 
 
 

Redhat 8 incorrectly sets hostname

Post by Russell Reaga » Fri, 13 Dec 2002 18:58:03



> What? That is not your host name. Just choose a name, and enter it into
> "hostname". That is why "hostname" exists. It is how you change your ...
> host name.

> If you are not on a LAN, this should finish the job. If you are on a LAN,
> put the hostname you chose into /etc/hosts along with your local IP.

So if I do `hostname google.com` and then go to work, I should be able

right? Don't think so...

Maybe I am confusing host name with domain name (shrug)? What I want is
for hostname to not give me my mac address, but rather
12-210-154-154.client.attbi.com. I can get this via host `ifconfig ...`,
but I'm wondering why hostname doesn't work in the first place.

I want to be able to look at my command prompt, or login screen, or type
hostname, or anywhere else it's SUPPOSED to be correct, and see what my
hostname is (since it changes every now and then) so I can ssh in from
school or work. Not to mention that gnome already complains that the
host name isn't correct.

It's also entirely possible that I'm missing the point of what a host
name is completely. Maybe you can clarify. An example. At school we have
a solaris machine named clyde (and its partner bonnie). When you login,
it says "Welcome to clyde". The hostname command outputs "clyde". When I

the machine's hostname is set to clyde have anything to do with the URL
I use to connect to it? Or is it just a coincidence? For example, if the
sys admin did a `hostname bob`, the login screen would say "Welcome to
bob", but the URL I would use to connect would still be
clyde.domain.edu, right?

It is my understanding that hostname is used to get the URL of the
machine. Perhaps this is where I am steering off into the weeds.

Thanks for your help.

Russell

 
 
 

Redhat 8 incorrectly sets hostname

Post by Ingo Paklepp » Fri, 13 Dec 2002 19:31:13


Do you use AT&T Cable? Several people repeated this problem. I don't
recall the solution, but maybe a google search will help?

> When I login, I am greeted with 'Welcome to x1-6-00-10-b5-6b-0d-53'. My

> warns that it cannot resolve the hostname x1-6-00-10-b5-6b-0d-53 and may
> cause some things to work incorrectly. echo $HOSTNAME and /bin/hostname
> both report the same string ("x1-6...").

> My efforts so far have resulted in me creating a small script (see
> below) to pull my ip address out of the output from ifconfig. I'm not
> sure if this is a viable solution, and if it is, I don't know how to
> convert the ip address to a hostname, and I also don't know where to set
> my hostname with this script during the bootup. I located multiple
> scripts in /etc that have the line HOSTNAME=`hostname` in it, but I
> wouldn't know which one to replace it in. Also, a better method would
> seem to be to set the hostname returned from my script via the hostname
> command, and let it report the changed hostname.

> #!/bin/sh
> /sbin/ifconfig |
>          grep 'inet addr:' |
>          grep -v '127.0.0.1' |
>          awk '{print $2}' |
>          awk -F: '{print $2}'

> I would like for my machine's hostname to be correctly identified, in
> the correct way if possible (I'm not sure my script workaround isn't
> going to cause problems elsewhere).

> I'm running Redhat 8 on a dual P3 733, 512 MB RAM, with a cable internet
> connection shared by 4 computers through a hub (all different IP's).

> Russell

 
 
 

Redhat 8 incorrectly sets hostname

Post by Burrito Warrio » Fri, 13 Dec 2002 22:43:37


On Thu, 12 Dec 2002 09:58:03 +0000, the artist formerly known as Russell
Reagan proclaimed:

> So if I do `hostname google.com` and then go to work, I should be able

> right? Don't think so...

No, you won't.  But the hostname of your machine will be
hostname.google.com.

Quote:> Maybe I am confusing host name with domain name (shrug)?

You are.

Quote:> What I want is
> for hostname to not give me my mac address, but rather
> 12-210-154-154.client.attbi.com. I can get this via host `ifconfig ...`,
> but I'm wondering why hostname doesn't work in the first place.

This can be done, because I had this happen to my accidentally on a red
hat 7.x series, but I don't know how you set it up, but don't worry, cuz
thereps more coming...

Quote:> I want to be able to look at my command prompt, or login screen, or type
> hostname, or anywhere else it's SUPPOSED to be correct, and see what my
> hostname is (since it changes every now and then) so I can ssh in from
> school or work. Not to mention that gnome already complains that the
> host name isn't correct.

All 12-210-154-154.client.attbi.com, is, in your example, is your IP
address plus other info at&t is giving you.  To reach your machine, all
you need is the IP address portion.  If you want to ssh to your machine
from work, you would just ssh to 12.210.154.154.

> It's also entirely possible that I'm missing the point of what a host
> name is completely. Maybe you can clarify. An example. At school we have
> a solaris machine named clyde (and its partner bonnie). When you login,
> it says "Welcome to clyde". The hostname command outputs "clyde". When I

> the machine's hostname is set to clyde have anything to do with the URL

That is because the university owns the entire domain, thus they are in
control of their DNS server/records and clyde.domain.edu is always mapping
to IP address 1.2.3.4 (whatever the actual IP address is).  So when you do

and the machine is actually doing an ssh to 1.2.3.4.  Humans speak words,
computers speak numbers.  The reason you can't use the name/hostname for
your home machine is you don't own the attbi.com domain, and as such, you
are getting a different ip address dynamically.  So if you set your
hostname to you.domain.com, that will be 1.2.3.4 one day, and 5.6.7.8 the
next.

Quote:> I use to connect to it? Or is it just a coincidence? For example, if the
> sys admin did a `hostname bob`, the login screen would say "Welcome to
> bob", but the URL I would use to connect would still be
> clyde.domain.edu, right?

Most likely yes, unless the sysadmin also updated the dns records to point
bob.domain.edu to the same box/ip address.

Quote:> It is my understanding that hostname is used to get the URL of the
> machine. Perhaps this is where I am steering off into the weeds.

Like I said earlier, the hostname can be anything, it is what is in the
DNS records that matters.  For convenience (and sanity's sake) the
university is mapping clyde.domain.edu in the DNS records, to the box with
hostname cyde.domain.edu.  They *could* map clyde.domain.edu to
anymachine.domain.edu that they wanted.

Hope that makes sense and I haven't added to your confusion.

Quote:> Thanks for your help.

> Russell

--
One OS to rule them all, One Passport to find them,
DRM to bring them all and with the EULA bind them.
 
 
 

1. My hostname will not set; dip error "must set HOSTNAME first"

I am trying to set up the NET-2 stuff to get a slip connection
going and have a couple questions.

Everything seems to have gone well, but when I get all the way
to using dip, and typing "mode SLIP", I get the error message
"must set HOSTNAME first".

Now, HOSTNAME is set in my environment, I have even exported it.
I have a file /etc/HOSTNAME with one line in it:
boo.ori.org

My hosts file looks like so:
192.68.202.232          boo
192.68.202.0            network
127.0.0.1               localhost

Running ifconfig gives me this:
lo        IP ADDR 127.0.0.1  BCAST 127.255.255.255  NETMASK 255.0.0.0
          MTU 2000  METRIC 0  POINT-TO-POINT ADDR 0.0.0.0
          FLAGS: 0x0049 ( UP LOOPBACK RUNNING )

Anyone have an idea of what is going on?

2. How to determine identity of socket listener

3. hostname resetting incorrectly

4. online discussion on Palladium

5. /bin/hostname -S won't set hostname

6. Windows 95, what a joke

7. Set up DNS to resolve hostname to hostname:port?

8. ANSI Labeled Tapes

9. Setting hostname on Redhat 8.0

10. Tin , Incorrectly set up ??

11. execve setting capabilities incorrectly ?

12. Pine sets reply-to address incorrectly

13. incorrectly set netmask