LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 09:46 PM   #1
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Rep: Reputation: 158Reputation: 158
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, 10:07 PM   #2
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,588

Rep: Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227
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, 11:10 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,581

Rep: Reputation: 480Reputation: 480Reputation: 480Reputation: 480Reputation: 480
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, 02:33 AM   #4
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
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, 10:09 AM   #5
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,517

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
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, 02:20 PM   #6
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
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, 07:05 PM   #7
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,517

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
'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, 09:42 PM   #8
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
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 09:43 PM.
 
Old 04-03-2013, 09:46 PM   #9
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
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, 11:36 PM   #10
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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, 01:18 PM   #11
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
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


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 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 12:24 PM
[SOLVED] Hostname does not persist on LAN int0x80 Linux - General 3 12-07-2011 10:41 AM
Access to hostname on LAN and WAN Zilvermeeuw Linux - Networking 11 08-02-2011 12:16 AM
what services rely on hostname? sdave1284 Linux - Networking 1 02-12-2004 07:25 AM
Ping a computer in LAN using hostname seven Linux - Networking 3 07-05-2003 11:42 PM


All times are GMT -5. The time now is 09:59 AM.

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