LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-02-2013, 08:46 PM   #1
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
How to access services on LAN using a hostname?


I have several servers running on my LAN that I want to be accessible to other LAN systems by hostname. NFS, SSH, FTP, WebDAV, and HTTP are a few. I currently have to enter the local IP address of the system that runs the service to access it from another system. For example, I have to type "ssh username@192.168.1.5" to access the ssh server on that system. I'd like to be able to use a hostname instead of the IP address, like "ssh username@hostname".

What do I need to set up on my LAN to make that possible?
 
Old 04-02-2013, 09:07 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you can setup DNS, but how to do that is beyond the scope of this post.
Alternatively, if the number of hosts is sufficiently small (and sufficiently static) you may prefer to maintain the /etc/hosts file on each host. In each /etc/hosts file add a line for each host on your network. Eg

Code:
192.168.1.5 mediapc
192.168.1.6 desktop
192.168.1.7 notebook
For more information
Code:
man 5 hosts
Evo2.
 
Old 04-02-2013, 10:10 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
you can do as evo2 suggests or if you are in control over your DNS server, you can add the hosts there as well.

I use a combination of both as i run in a very mixed environment. win7, OSx, and Linux (both CentOS server and F18 laptop). The combination works great for me.
 
Old 04-03-2013, 01:33 AM   #4
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Original Poster
Rep: Reputation: 174Reputation: 174
Ok, thank you both. I have six systems on my LAN right now, four Linux (Slackware) and two Windows. I could manage host files on each, but I like the idea of using my DNS server. I am running named (bind) as a cacheing only nameserver on one of my systems. Here is my named.conf file:

Code:
options {
        directory "/var/named";
        /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
        // query-source address * port 53;
};

// 
// a caching only nameserver config
// 
zone "." IN {
        type hint;
        file "caching-example/named.root";
};

zone "localhost" IN {
        type master;
        file "caching-example/localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "caching-example/named.local";
        allow-update { none; };
};
What would it take to make it resolve local hostnames?
 
Old 04-03-2013, 09:09 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,377

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
As you have Windows machines, you may want to add 'wins' to the hosts line in /etc/nsswitch.conf as pointed out in this 5 star thread http://www.linuxquestions.org/questi...-samba-271336/

I cannot help with bind as I use dnsmasq.
 
1 members found this post helpful.
Old 04-03-2013, 01:20 PM   #6
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Original Poster
Rep: Reputation: 174Reputation: 174
allend, thank you for the link to that thread. Adding "wins" to the hosts options in the /etc/nsswitch.conf file did the trick for me.

I've never updated the nsswitch.conf file before today. I'm not really clear what is affected by it, or what uses it. I've been reading about it, but I don't understand why adding the wins (Windows Internet Name Server, apparently) parameter allows my local host names to be resolved on my linux systems. Do you have any idea?
 
Old 04-03-2013, 06:05 PM   #7
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,377

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
'man nsswitch.conf' is more definitive, but adding 'wins' adds an additional service for building the 'hosts' database used by the GNU C library for obtaining name-service information.
i.e. You are telling Linux to also handle the information provided by Windows via wins.
 
Old 04-03-2013, 08:42 PM   #8
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Original Poster
Rep: Reputation: 174Reputation: 174
Ok, that makes sense.

Just to see if I could achieve the same thing using bind (named), I removed the wins keyword from nsswitch.conf, verified that name resolution went back to the way it was before (i.e., local host names not resolving on the linux systems), then changed my /etc/named.conf to make my DNS server authoritative for my own domain name (a master server). I also set up a slave DNS server on another system on my network. It worked just as well for the systems on my network that have static IP addresses. So it appears you can get local host name resolution via a bind server or wins.

Now I just have to figure out how to get my bind named server to handle the dynamically assigned IP addresses. The majority of the systems and appliances on my network get an IP address from the DHCP server that I run on the same system that hosts my DNS master server.

I believe I'm going to stick with the bind setup, but it's good to know that adding wins to nsswitch allows a Windows system running a wins server on the local network to resolve local host names too.

Last edited by Z038; 04-03-2013 at 08:43 PM.
 
Old 04-03-2013, 08:46 PM   #9
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Original Poster
Rep: Reputation: 174Reputation: 174
I've marked my thread "Solved" because my original question is answered. But if anyone has any insight into how to resolve hostnames for systems with dynamically assigned IP addresses using bind, I'd like to hear.
 
Old 04-03-2013, 10:36 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I think you want to look at ddns-update-style
http://www.linuxtopia.org/online_boo...ml#config-file
http://linux.die.net/man/5/dhcpd.conf
 
1 members found this post helpful.
Old 04-04-2013, 12:18 PM   #11
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Original Poster
Rep: Reputation: 174Reputation: 174
Chris, thanks for the suggestion. It took me a few tries to get it set up right, but I've now got my dhcp server sending dynamic DNS updates to my master bind server whenever a lease changes. The host names for all of my systems are now resolving correctly from anywhere on my LAN.

I still need to review security settings in both bind and dhcpd, get my secondary DNS server squared away, and maybe set up failover for my dhcp server.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
clients CAN resolve hostname of server w/nslookup, but CANNOT access by hostname WTF? psycroptic Linux - Networking 9 11-10-2012 11:24 AM
[SOLVED] Hostname does not persist on LAN int0x80 Linux - General 3 12-07-2011 09:41 AM
Access to hostname on LAN and WAN Zilvermeeuw Linux - Networking 11 08-01-2011 11:16 PM
what services rely on hostname? sdave1284 Linux - Networking 1 02-12-2004 06:25 AM
Ping a computer in LAN using hostname seven Linux - Networking 3 07-05-2003 10:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:42 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