Networking Forums

Networking Forums > Computer Networking > Linux Networking > /bin/hostname

Reply
Thread Tools Display Modes

/bin/hostname

 
 
Vwaju
Guest
Posts: n/a

 
      08-22-2008, 07:55 PM
I am having trouble with my Debian Linux network configuration, and I
am trying to isolate the problem. The name of my host is "jupiter"
and the name of my domain is "obliqueuniverse.org".

jupiter:~# echo jupiter.obliqueuniverse.org > /etc/hostname

jupiter:~# cat /etc/hosts | sed –n 1p
127.0.0.1 localhost.localdomain localhost jupiter

jupiter:~# cat /etc/hosts | sed –n 4p
207.237.37.110 jupiter.obliqueuniverse.org jupiter

I believe that /bin/hostname without options should output the host
name "jupiter", but it doesn't. Here's what I get when I run /bin/
hostname:

jupiter:~# /bin/hostname -–domain
obliqueuniverse.org # AS EXPECTED

jupiter:~# hostname –-fqdn
jupiter.obliqueuniverse.org # # AS EXPECTED

jupiter:~# /bin/hostname –-ip-address
207.237.37.110 # AS EXPECTED

jupiter:~# /bin/hostname –short
jupiter # AS EXPECTED

jupiter:~# /bin/hostname –nis
(none) # ? ? ?

jupiter:~# /bin/hostname
jupiter.obliqueuniverse.org # EXPECTED "jupiter"

jupiter:~# /bin/hostname –F /etc/hostname
<NO OUTPUT> # EXPECTED "jupiter"

jupiter:~# /bin/hostname –-alias
jupiter # NOW HOSTNAME IS PRINTED!

Can anyone shed light on the last 4 results?

Thanks & Best Regards,

Vwaju
New York City
 
Reply With Quote
 
 
 
 
Bit Twister
Guest
Posts: n/a

 
      08-22-2008, 08:16 PM
On Fri, 22 Aug 2008 12:55:59 -0700 (PDT), Vwaju wrote:
> I am having trouble with my Debian Linux network configuration, and I
> am trying to isolate the problem. The name of my host is "jupiter"
> and the name of my domain is "obliqueuniverse.org".
>
> jupiter:~# echo jupiter.obliqueuniverse.org > /etc/hostname
>
> jupiter:~# cat /etc/hosts | sed –n 1p
> 127.0.0.1 localhost.localdomain localhost jupiter
>
> jupiter:~# cat /etc/hosts | sed –n 4p
> 207.237.37.110 jupiter.obliqueuniverse.org jupiter


grep jupiter /etc/hosts
127.0.0.1 localhost.localdomain localhost jupiter
207.237.37.110 jupiter.obliqueuniverse.org jupiter

Why do you have jupiter on more than one line.
Look at the ip address when you do a
ping -c1 jupiter


> I believe that /bin/hostname without options should output the host
> name "jupiter", but it doesn't.


Quick look in man hostname, indicates gethostname is used.
man gethostname shows CONFORMING TO
POSIX.1-2001
so I am going to guess hostname default is FQDN.


> jupiter:~# /bin/hostname –nis
> (none) # ? ? ?


Guessing your nis server is not running.


> jupiter:~# /bin/hostname
> jupiter.obliqueuniverse.org # EXPECTED "jupiter"


I would expect that on a POSIX compliant system.


> jupiter:~# /bin/hostname –F /etc/hostname
> <NO OUTPUT> # EXPECTED "jupiter"


You told hostname to set hostname from /etc/hostname, not display it.


> jupiter:~# /bin/hostname –-alias
> jupiter # NOW HOSTNAME IS PRINTED!


no surprise there because your earlier test showed
/bin/hostname –short
jupiter

 
Reply With Quote
 
Vwaju
Guest
Posts: n/a

 
      08-22-2008, 09:49 PM
On Aug 22, 4:16 pm, Bit Twister <BitTwis...@mouse-potato.com> wrote:
> On Fri, 22 Aug 2008 12:55:59 -0700 (PDT), Vwaju wrote:
> > I am having trouble with my Debian Linux network configuration, and I
> > am trying to isolate the problem. The name of my host is "jupiter"
> > and the name of my domain is "obliqueuniverse.org".

>
> > jupiter:~# echo jupiter.obliqueuniverse.org > /etc/hostname

>
> > jupiter:~# cat /etc/hosts | sed –n 1p
> > 127.0.0.1 localhost.localdomain localhost jupiter

>
> > jupiter:~# cat /etc/hosts | sed –n 4p
> > 207.237.37.110 jupiter.obliqueuniverse.org jupiter

>
> grep jupiter /etc/hosts
> 127.0.0.1 localhost.localdomain localhost jupiter
> 207.237.37.110 jupiter.obliqueuniverse.org jupiter
>
> Why do you have jupiter on more than one line.


I am working from Linux System Administration (LSA) Adelstein &
Lubanovic, O'Reilly, 2007 (p. 14). LSA is a detailed guide to building
an internet server on Debian Linux ("sarge"), which is what I am
running.

I added the second line (following LSA) because I am building an
internet server with a static IP address, and there needs to be a line
in /etc/hosts that maps the host and the FQDN to the static IP
address.

> Look at the ip address when you do a
> ping -c1 jupiter


jupiter:~# ping –c1 jupiter | sed –n 1p
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data

> > I believe that /bin/hostname without options should output the host
> > name "jupiter", but it doesn't.


According to LSA, if I execute
echo myserver.mydomain.org > /etc/hostname
and then
/bin/hostname –F /etc/hostname
then /bin/hostname should print "myserver" (the hostname w/o the
domain name)

What do you get on your system?

Thanks for helping a neophyte, Twister.

Best Regards,
Vwaju
New York City


 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      08-22-2008, 10:36 PM
On Fri, 22 Aug 2008 14:49:27 -0700 (PDT), Vwaju wrote:
> On Aug 22, 4:16 pm, Bit Twister <BitTwis...@mouse-potato.com> wrote:
>>
>> grep jupiter /etc/hosts
>> 127.0.0.1 localhost.localdomain localhost jupiter
>> 207.237.37.110 jupiter.obliqueuniverse.org jupiter
>>
>> Why do you have jupiter on more than one line.

>
>
> I added the second line (following LSA) because I am building an
> internet server with a static IP address, and there needs to be a line
> in /etc/hosts that maps the host and the FQDN to the static IP
> address.


I would remove jupiter from the 127.0.0.1 line.
I know when I ping jupiter I would want 207.237.37.110, not 127.0.0.1

> then /bin/hostname should print "myserver" (the hostname w/o the
> domain name)
>
> What do you get on your system?


Mandrvia 2008.1 fqdn
fedora 9 fqdn
slack 12.1 short name
kubuntu 8.04 short name
Mandrvia 2009.0 fqdn
pc linux 2007 fqdn
suse 10.3 short name
suse 11.0 short name
 
Reply With Quote
 
Vwaju
Guest
Posts: n/a

 
      08-25-2008, 07:56 PM
On Aug 23, 5:08 pm, ibupro...@painkiller.example.tld (Moe Trin) wrote:
> On Fri, 22 Aug 2008, in the Usenet newsgroup comp.os.linux.networking, in
> article <be279293-c8d6-4ea1-83db-4d5c3782c...@j22g2000hsf.googlegroups.com>,
>
> Vwaju wrote:
>
> NOTE: Posting from groups.google.com (or some web-forums) dramatically
> reduces the chance of your post being seen. Find a real news server.
>
> >Bit Twister <BitTwis...@mouse-potato.com> wrote:
> >> grep jupiter /etc/hosts
> >> 127.0.0.1 localhost.localdomain localhost jupiter
> >> 207.237.37.110 jupiter.obliqueuniverse.org jupiter

>
> >> Why do you have jupiter on more than one line.

>
> >I am working from Linux System Administration (LSA) Adelstein &
> >Lubanovic, O'Reilly, 2007 (p. 14). LSA is a detailed guide to building
> >an internet server on Debian Linux ("sarge"), which is what I am
> >running.

>
> "sarge" (version 3.1) was superseded about a bit over a year ago by
> "etch" (version 4.0). Use the command 'cat /etc/debian_version' to see
> what you are using. (It's a common problem that printed books are
> often dealing with old or even obsolete versions.) Please review the
> section about updating the system before you offer an older system to
> the bad d00ds on the Internet.
>
> >I added the second line (following LSA) because I am building an
> >internet server with a static IP address, and there needs to be a line
> >in /etc/hosts that maps the host and the FQDN to the static IP
> >address.

>
> That is correct, but why is it ALSO a nickname (alias) for localhost?
>
> The concept is that a name appears on one, and only one line in the
> /etc/hosts file. Likewise, an IP address should appear on one line
> only. Many operating systems will _tolerate_ having the same name or
> IP address on multiple lines, but it can give unexpected results.
>
> The 'localhost' alias of 'jupiter' isn't needed. If _ON_ 'jupiter'
> you want to send packets to 'jupiter' or 'jupiter.obliqueuniverse.org',
> the kernel will look at /etc/host.conf (old applications) or
> /etc/nsswitch.conf to see where/how to look up names.
>
> [compton ~]$ grep host /etc/host.conf /etc/nsswitch.conf
> /etc/host.confrder hosts,bind
> /etc/nsswitch.conf:hosts: files nis dns
> [compton ~]$
>
> Here, both files say to check the /etc/hosts file FIRST. Looking in
> your /etc/hosts file, it would find the rcn.com address. But the
> kernel is smart, and knows that this address is one of it's addresses
> and rather than clutter up the wire with useless noise, it would use
> the loopback address - it knows it is talking to itself, not some host
> out on the Internet.
>
> >then /bin/hostnameshould print "myserver" (the hostname w/o the
> >domain name)

>
> >What do you get on your system?

>
> Linux distributions are supposed to follow Linux Standard Base standards,
> and one of those is the Base Core Specification:
>
> ------------------
> Linux Standard Base Core Specification 3.2
>
> Section 15.2 Command Behavior
>
> Name
>
> hostname -- show or set the system's host name
>
> Synopsis
>
> hostname [name]
>
> Description
>
> hostname is used to either display or, with appropriate privileges, set
> the current host name of the system. The host name is used by many
> applications to identify the machine.
>
> When called without any arguments, the program displays the name of the
> system as returned by the gethostname() function.
>
> When called with a name argument, and the user has appropriate
> privilege, the command sets the host name.
>
> Note: It is not specified if the hostname displayed will be a fully
> qualified domain name. Applications requiring a particular format of
> hostname should check the output and take appropriate action.
>
> ------------------
>
> See that note on the end of the requirement? It always is a good idea
> to look at the manual page for commands you are unfamiliar with. As Bit
> shows in his response, you may get different results depending on which
> distribution you are using. And by the way, my systems also return the
> FQDN.
>
> Old guy


Thank you for the helpful pointers, Old Guy. I had read the man page
for hostname, but was not aware of the Linux Standard Base Core
Specification 3.2)

Best Regards,
Vwaju
NYC
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get hostname from IP address??? Neroku Linux Networking 4 04-22-2007 01:04 AM
Hostname Bit Twister Linux Networking 26 09-23-2004 06:27 AM
change hostname faeychild Linux Networking 9 11-01-2003 03:10 PM
ping <hostname> Kamir Wolfgang Linux Networking 7 09-17-2003 06:37 AM
Re: How to change hostname? Xyerp Linux Networking 0 07-04-2003 09:17 AM



1 2 3 4 5 6 7 8 9 10 11