Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
07-24-2012, 02:08 PM
|
#1
|
LQ Newbie
Registered: Jul 2012
Posts: 6
Rep: 
|
host host_name do not retrive IP - how to set a loopback?
Hello,
I've an CentOS 6.3 fresh installation where I want to install an application which has this requirement:
"TCP/IP and DNS must be installed; the command host host_name (where host_name is the name of your host) must return the IP address of the host"
I can set a static IP. I can access to internet. I dont know how to make the "host host_name" works as supposed. I tried some configurations and it never retrived the IP.
My static IP is 192.168.68.128 an the IP which should work to this application should be 172.16.8.57. On windows I used to resolve this situation with a loopback. On CentOS I'm a newbie and I dont know how to correctly define my loopback.
Can you help me?
|
|
|
07-24-2012, 03:12 PM
|
#2
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
I'm confused... all you need to be able to do is resolve your hostname to an IP. This is configured for you by default.
Run the following:
Code:
host $(echo $HOSTNAME)
|
|
|
07-24-2012, 03:15 PM
|
#3
|
LQ Newbie
Registered: Jul 2012
Posts: 6
Original Poster
Rep: 
|
Hi Kustom42,
Thank you.
The result to your command:
Code:
host $(echo $HOSTNAME)
is:
Code:
Host epagesdevlinux01 not found: 3(NXDOMAIN)
Regards,
Helio
|
|
|
07-24-2012, 03:20 PM
|
#4
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
Ok, so just add it to your etc hosts file.. it should have done that for you during the initial install but if you changed your hostname it wouldnt have updated.
Find the line that has your external static IP on it. If there is not a line with it there add it. Syntax is as follows:
Code:
1.1.1.1 epagesdevlinux01 epagesdevlinux01.domain.com anyother.host.name
The IP comes first followed by your hostnames, they can be space or tab delimitted it does not matter. You should be good to re-run the host command and resolve it to your IP now.
|
|
|
07-24-2012, 03:26 PM
|
#5
|
LQ Newbie
Registered: Jul 2012
Posts: 6
Original Poster
Rep: 
|
Adding it to hosts files I've this:
Code:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.91 epagesdevlinux01 epagesdevlinux01.domain.com anyother.host.name
"192.168.1.91" is my static IP on my local network.
Runing the host command again I get the same result
Code:
Host epagesdevlinux01 not found: 3(NXDOMAIN)
Is my hosts file right?
|
|
|
07-24-2012, 03:29 PM
|
#6
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
Yes your hosts file syntax is right but the epagesdevlinux01.domain.com anyother.host.name were provided as examples, you don't need these unless you want to add more domains.
You may have to restart networking or the server to get it to find the hosts file update but it is odd as usually the change is effective immediately
|
|
|
07-24-2012, 03:33 PM
|
#7
|
Moderator
Registered: Mar 2008
Posts: 22,273
|
Just put the name and none of that other stuff behind it.
|
|
|
07-24-2012, 05:17 PM
|
#8
|
Member
Registered: Nov 2009
Posts: 55
Rep:
|
Hi,
host will do a dns lookup, as your host is local and not declared on the dns server, you will not be able to resolve it.
You can put whatever you want on /etc/hosts this will not change unless you put the right name.
Now if the application you want to install have to be used from internet, then you have to open the port and give the real internet name to your host.
The real name of your fresh centos should be equal to the result of :
host <external real internet ip>
|
|
|
07-24-2012, 05:38 PM
|
#9
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
Quote:
Originally Posted by Chirel
Hi,
host will do a dns lookup, as your host is local and not declared on the dns server, you will not be able to resolve it.
You can put whatever you want on /etc/hosts this will not change unless you put the right name.
Now if the application you want to install have to be used from internet, then you have to open the port and give the real internet name to your host.
The real name of your fresh centos should be equal to the result of :
host <external real internet ip>
|
You are talking about PTR and DNS with your last few lines, this is not a factor in this equation as no external DNS is being served or being called upon, your /etc/hosts file is checked prior to DNS lookups. Your statement that it will not be able to resolve it is completely false.
|
|
|
07-24-2012, 06:40 PM
|
#10
|
Member
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179
Rep:
|
Quote:
Originally Posted by Kustom42
You are talking about PTR and DNS with your last few lines, this is not a factor in this equation as no external DNS is being served or being called upon, your /etc/hosts file is checked prior to DNS lookups. Your statement that it will not be able to resolve it is completely false.
|
The host command search in nameserve define in /etc/resolv.conf.
Is the server hostname is in DNS Server with host record and PTR record.
|
|
|
07-24-2012, 06:50 PM
|
#11
|
LQ Newbie
Registered: Jul 2012
Posts: 6
Original Poster
Rep: 
|
So, i adjusted the hosts file:
Code:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.91 epagesdevlinux01
I restarted the network service
Code:
sudo service network restart
And trying the host command... I get the same result.
I reboot the server and I get the same result.
Code:
Host epagesdevlinux01 not found: 3(NXDOMAIN)
Later I will use the MyServer.domain.com, but now, just for test purposes I'm using a local name (without domain).
I can use a hostname with domain and just define it on /etc/hosts, but the result will be the same as using a local name, right?
|
|
|
07-24-2012, 06:53 PM
|
#12
|
Member
Registered: Nov 2009
Posts: 55
Rep:
|
@ Kustom42
Sorry, but i really think that you are wrong, the host command will alway try to resolve via a dns lookup from /etc/resolv.conf - it will not check /etc/hosts.
the only way other way he can solve this problem is to install a personal bind server and setup /etc/resolv.conf with it.
You can put what you want into the /etc/hosts this will never change the host command behaviour.
host will not use /etc/nsswitch.conf to resolve host name, it will only use /etc/resolv.conf and nothing else.
For hfelix
the application you want to install check that you are using a host that is known from current dns server.
As you are using internet the real ip is the external ip with is the result of the command
And the host name that is associated is the result of
Code:
host $(curl icanhazip.com)
So if you want to install the application you have to simulate that you are this host and change your hostname to this.
Last edited by Chirel; 07-24-2012 at 07:04 PM.
|
|
|
07-24-2012, 07:08 PM
|
#13
|
Member
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179
Rep:
|
Quote:
Originally Posted by Chirel
@ Kustom42
Sorry, but i really think that you are wrong, the host command will alway try to resolve via a dns lookup from /etc/resolv.conf - it will not check /etc/hosts.
the only way other way he can solve this problem is to install a personal bind server and setup /etc/resolv.conf with it.
You can put what you want into the /etc/hosts this will never change the host command behaviour.
host will not use /etc/nsswitch.conf to resolve host name, it will only use /etc/resolv.conf and nothing else.
For hfelix
the application you want to install check that you are using a host that is known from current dns server.
As you are using internet the real ip is the external ip with is the result of the command
And the host name that is associated is the result of
Code:
host $(curl icanhazip.com)
So if you want to install the application you have to simulate that you are this host and change your hostname to this.
|
It is DNS lookup utility. any how it will search the DNS where its domain name is defined. hence resolv.conf come into that picture.
below is man page of host.
HOST(1) BIND9 HOST(1)
NAME
host - DNS lookup utility
SYNOPSIS
host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type]
[-W wait] [-m flag] [-4] [-6] {name} [server]
DESCRIPTION
host is a simple utility for performing DNS lookups. It is normally
used to convert names to IP addresses and vice versa. When no arguments
or options are given, host prints a short summary of its command line
arguments and options.
name is the domain name that is to be looked up. It can also be a
dotted-decimal IPv4 address or a colon-delimited IPv6 address, in which
case host will by default perform a reverse lookup for that address.
server is an optional argument which is either the name or IP address
of the name server that host should query instead of the server or
servers listed in /etc/resolv.conf.
|
|
|
07-25-2012, 02:22 AM
|
#14
|
Member
Registered: Nov 2009
Posts: 55
Rep:
|
Quote:
Originally Posted by sharadchhetri
It is DNS lookup utility. any how it will search the DNS where its domain name is defined. hence resolv.conf come into that picture.
below is man page of host.
HOST(1) BIND9 HOST(1)
NAME
host - DNS lookup utility
SYNOPSIS
host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type]
[-W wait] [-m flag] [-4] [-6] {name} [server]
DESCRIPTION
host is a simple utility for performing DNS lookups. It is normally
used to convert names to IP addresses and vice versa. When no arguments
or options are given, host prints a short summary of its command line
arguments and options.
name is the domain name that is to be looked up. It can also be a
dotted-decimal IPv4 address or a colon-delimited IPv6 address, in which
case host will by default perform a reverse lookup for that address.
server is an optional argument which is either the name or IP address
of the name server that host should query instead of the server or
servers listed in /etc/resolv.conf.
|
That's exactly what i'm saying. So host command will ignore any change to /etc/hosts, that's what i'm trying to say to Kustom42.
|
|
|
07-25-2012, 04:25 AM
|
#15
|
Member
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179
Rep:
|
Quote:
Originally Posted by Chirel
That's exactly what i'm saying. So host command will ignore any change to /etc/hosts, that's what i'm trying to say to Kustom42.
|
best practice is create a internal DNS server.
Ask your system admin to create a internal DNS.With A and PTR record for the application Server
put the internal DNS server ip in /etc/resolv.conf
|
|
|
All times are GMT -5. The time now is 11:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|