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 12-26-2012, 06:47 PM   #1
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Rep: Reputation: Disabled
Hostname -i not showing up correctly


We have modified our /etc/hosts to something like this
Code:
127.0.0.1   localhost localhost.localadmin gyapp
and when we run hostname -i we get hostname: Unknown host. Have restarted the network service yet the same.
 
Old 12-27-2012, 04:42 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,610

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
'hostname -i' doesn't seem to return 127.0.0.1
What do you really want to achieve with this?
 
Old 12-27-2012, 10:04 AM   #3
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Nevem,
What I want to do is to monitor a java application remotely. The java application running via a wrapper. So I followed this link http://stackoverflow.com/questions/8...jmx-connection where it talks possible the hostname issue. So this is what I want to do and stuck with the hostname thing.
 
Old 12-27-2012, 10:26 AM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,506

Rep: Reputation: 233Reputation: 233Reputation: 233
/etc/hostname

/etc/hosts


Does

$ hostname --all-ip-addresses

return the same information as

$ hostname -i

?
 
Old 12-27-2012, 10:53 AM   #5
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 301

Rep: Reputation: 60
Which distro are you running? The hostname is set in 2 files, /etc/hosts and one more, which can be different on different distros, but often /etc/hostname.

To give you an example, this is what I have in Salix:
Code:
/etc/hosts
127.0.0.1		localhost
192.168.1.xx		salix.mydomain salix
If you don't have static ip you can use 127.0.1.1 instead. (It is not recommended to put your hostname on 127.0.0.1.)
Code:
/etc/HOSTNAME
salix.mydomain
 
Old 12-27-2012, 11:16 AM   #6
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Lennie,
Mine is centos 6.3 and my current /etc/hosts shows as below
Quote:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
 
Old 12-27-2012, 11:43 AM   #7
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 301

Rep: Reputation: 60
That looks ok, but you also need to add a line with your hostname.
Code:
127.0.1.1 yourhostname
In addition to that you need another file for your hostname. Do you have /etc/hostname? I don't have CentOS (or something based on it) so I can't check which file it uses.

Edit: Here I found out the file you also need to change is /etc/sysconfig/network.

Last edited by Lennie; 12-27-2012 at 11:46 AM.
 
Old 12-27-2012, 01:19 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,610

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
So you don't know your own IP-addr?
Try 'ifconfig' or 'route -n'.
 
Old 12-27-2012, 06:44 PM   #9
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Lennie,
You mean to say just add a new line and put this 127.0.1.1 yourhostname ? I have checked there is no /etc/hostname.
 
Old 12-27-2012, 06:45 PM   #10
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Nevem,
I know my ip address that is not a problem at all. The issue is the hostname. What will this hostname be applied to? So any one can just put the host name instead of the ip will be able to connect to the machine?
 
Old 12-27-2012, 10:09 PM   #11
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,506

Rep: Reputation: 233Reputation: 233Reputation: 233
That's kind of how microsofts netbeau(sp?) works. Any computers with the same workgroup name can mount each others shares and swap files, without the other person even knowing it.


/etc/hostname is what gets modified on some systems by an interface named hostname.

$ man hostname

If it differs for your distro, the man page probably hints as to what it is called on your system under FILES towards the bottom of the man page. Man as in manual. The /etc/hosts file is more of a localized DNS lookup table. But not everything uses it, so it depends on "what" you are trying to do.
 
Old 12-28-2012, 02:50 AM   #12
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 301

Rep: Reputation: 60
Did you see the edit in my previous post? The page I linked to shows some example. You should use /etc/sysconfig/network instead of /etc/hostname. You can give whatever name you want to your system. The only important thing is that it is the same in /etc/hosts (the last line, which you need to add) and in /etc/sysconfig/network.
 
Old 12-28-2012, 06:37 AM   #13
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Shadow,
My problem is I need to link remotely to the machine via the visual jvm tool to monitor the java application. Do you think the hostname could be a problem?
 
Old 12-28-2012, 06:39 AM   #14
newbie14
Member
 
Registered: Sep 2011
Posts: 403

Original Poster
Rep: Reputation: Disabled
Dear Lennie,
Sorry I missed that will try the link and it looks complete hopefully that will be helpful to solve my other problem of the visual jvm. Thank you.
 
Old 12-28-2012, 06:09 PM   #15
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,506

Rep: Reputation: 233Reputation: 233Reputation: 233
I'm not familiar with the jvm tool you're referencing. But is the routing okay? Can you ping one and it can ping you. Which are icmp packets.

# route -n
# netstat -r

If you can't do that much then there probably is a firewall in the way. Or other issues if you get stuff like host unreachable. You really can't work on getting the jvm working if the basic networks are not connected. Honestly I don't see why hostname would be the problem. Unless you have multiple instance running in virtualization and need to isolate only one of them. From the linked to content you seem to referencing the tool by IP:PORT.

On rare occassion when my ISP DNS's (and/or others) suck, I have had to put the IP and hostname of the external site in my local hosts file. The IP alone is not sufficient if there are multiple sites hosted at that same IP address. Which is common in webhosting, without paying extra. Although this approach is more of a hack than the way you "should" do things. (In a perfect world my ISPs dns servers wouldn't suck).
 
  


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
Hostname issue - showing "localhost" instead of actual hostname. ryes31 Linux - Server 9 12-12-2012 08:19 PM
Linux machine not reporting hostname correctly MJBoa Linux - Networking 3 11-19-2009 06:08 AM
Accented characters not showing correctly. Mol_Bolom Linux - General 1 06-06-2009 04:59 AM
My hostname is NOT resolving correctly cucolin@ Linux - Networking 5 08-29-2007 10:22 AM
How do I correctly set a hostname? MiGI Linux - Software 1 03-17-2006 04:03 PM


All times are GMT -5. The time now is 11:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration