LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 04-04-2017, 01:40 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
About configuring hostname resolution statically or dynamically


Static hostname resolution configuration is done in /etc/hosts.

It looks like dynamic hostname resolution configuration is done using
resolv.conf file. But from what I know, this file is generated
by another utility (See below).

So to do dynamic hostname resolution configuration, I can use nmtui or nmcli utility to add DNS ip address.

Local host use DNS for IP address lookup when local host cannot find
IP specified in /etc/hosts.

Here is resolv.conf for Linux Mint 18:
Code:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search Home

Here is resolv.conf for CentOS 7:
Code:
# Generated by NetworkManager
nameserver 192.168.122.1
From man resolv.conf:
Quote:
....
nameserver Name server IP address
Internet address of a name server that
the resolver should query, either an IPv4 address
(in dot notation), or an IPv6 address in
colon (and possibly dot) notation as per RFC 2373.
... ...
Q1: Since the addresses (127.0.1.1 & 192.168.122.1)
in resolv.conf for the above
nameserver directive are local,
how do I locate these nameservers in local host?

From man resolv.conf:
Quote:
... ...
search Search list for host-name lookup.
The search list is normally determined from the
local domain name; by default, it contains
only the local domain name. This may be
changed by listing the desired domain search
path following the search keyword with spaces
or tabs separating the names. Resolver queries
having fewer than ndots dots (default is 1)
in them will be attempted using each component of
the search path in turn until a match is found.
... ...
Q2: About directive "search Home" in resolv.conf,
what is it looking for in Home directory?
There are only files and directories in Home.
What did I missed?


Thank you.

Last edited by fanoflq; 04-04-2017 at 01:43 PM.
 
Old 04-04-2017, 07:20 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
CentOS 7
If your system is configured for DHCP then it will usually get the DNS name server from the the DHCP server which is normally the router in a home system. Via NetworkManager you can use other DNS name servers not provided by the DHCP server as well as enter everything manually including disabling NM completely.

Mint 18
dnsmasq is installed and running which uses the computer for a local DNS caching server which is why you see 127.0.1.1. You can also provide a search list which is usually the local domain name. I assume you used Home for a domain name when you installed Mint. AFAIK if you use mysite in the web browser it will automatically try http://mysite.home/

Last edited by michaelk; 04-04-2017 at 08:08 PM.
 
1 members found this post helpful.
Old 04-04-2017, 07:58 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,974

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
It would not search /home. I'd think that someone/somehow placed a "name" as home. Like in computer name or domain name.

Last edited by jefro; 04-04-2017 at 08:01 PM.
 
1 members found this post helpful.
Old 04-04-2017, 10:58 PM   #4
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
So how do I remove "search Home" since resolv.conf
was generated by another utility?
 
Old 04-05-2017, 01:00 AM   #5
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
What's in /etc/network/interfaces file ?
 
Old 04-05-2017, 08:00 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
The resolvconf script generates the contents of the resolv.conf file.
 
Old 04-05-2017, 11:39 AM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mddnix View Post
What's in /etc/network/interfaces file ?

Mint 18
Code:
                                                                 
$ cat  /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
CentOS7:
Code:
[root@centos7-1024ram-minimal ~]# cd /etc/network
-bash: cd: /etc/network: No such file or directory
[root@centos7-1024ram-minimal ~]# cat /etc/networks 
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0
 
Old 04-05-2017, 03:46 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,974

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
I might as well ask this. What is result of command "hostname" ? no quotes.
 
  


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
setup hostname from DNS/DHCP dynamically nicolasdiogo Linux - Networking 6 12-27-2012 03:52 PM
Link one library statically others dynamically (gcc, g++) czappa Programming 7 03-22-2012 08:47 AM
Hostname resolution diogosalazar Linux - Networking 1 03-16-2011 12:27 PM
How to make a linux machine with a static IP address dynamically add its hostname to jrwsod LinuxAnswers Discussion 1 02-15-2010 08:46 PM
Dynamically loaded modules and statically loaded modules in linux gauthamk Linux - Software 1 05-18-2008 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:34 PM.

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