[SOLVED] How to access services on LAN using a hostname?
Linux - GeneralThis 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
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.
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.
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?
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
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.
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?
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?
'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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.