Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a small device running Linux with a web server on it. I want it to be plug and play, connect to a network and access to it using an abstract name.

Is it possible to access to a device using only its hostname?

share|improve this question
up vote 9 down vote accepted

On some networks – yes. But on your everyday TCP/IP network, the hostname must be translatable to an IP address, otherwise clients will not know what to connect to.

There are several existing protocols for local name lookup, though:

  • Windows uses NetBIOS name services for resolving hostnames of other computers in the same LAN, using UDP broadcasts. Your server will need to run the nmbd component of Samba to be discoverable using NetBIOS.

    (Recent Windows versions also support LLMNR, which is similar to mDNS but has fewer features and requires IPv6. On Linux, systemd-resolved will have a LLMNR client. No idea about other operating systems. Probably not worth considering.)

  • OS X uses mDNS ("multicast DNS"), sometimes known as Bonjour, for the same purposes. (Note that mDNS generally does not resolve bare hostnames like NetBIOS would; instead, it is limited to the .local domain.) For mDNS, your server will need avahi-daemon.

    (Also, Windows can resolve mDNS names if Bonjour is installed (typically as part of iTunes), and OS X should support NetBIOS if "Windows file sharing" or a similar service is enabled.)

  • Desktop-oriented Linux systems often come with both NetBIOS and mDNS resolvers preconfigured. (That is, they run both nmbd and avahi-daemon, plus the relevant glibc NSS modules in /etc/nsswitch.conf.)

  • Finally, most "home routers" maintain a local DNS domain (.lan, .home, &c.) according to hostnames they receive from DHCP requests sent by computers in the LAN. Depending on what your server uses, dhcpcd needs the "hostname" option, while dhclient uses "send host-name = gethostname()".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.