0

I mean, why IP addresses are not sufficient? We can identify devices by their IP addresses. Why do we want to use hostnames? To identify devices?

I know that IP addresses are assigned in a random way (from a certain range). What about the host names? How are they assigned?

Roman
  • 2,569
  • 10
  • 32
  • 32

2 Answers2

2

On all the zeroconf devices I've used the hostname is actually set on the device. On a Mac this comes from the computer name you set for your system. On my Linux and OpenSolaris machines it's the system hostname.

Kamil Kisiel
  • 12,184
  • 7
  • 48
  • 69
  • Do I correctly understand? The hostnames are not set automatically by the zeroconf. User sets a name for the computer and this name is used by zeroconf as the hostname for this computer. What if 2 computers have the same name? – Roman Mar 03 '10 at 21:10
  • Well, they are not set by the protocol. The application implementing the zeroconf service on your platform (Avahi in the case of Linux) takes care of setting the hostname it publishes via mDNS. It defaults to the system hostname but you could change it to something else. I'm unsure as to what happens if two machines attempt to publish the same hostname. – Kamil Kisiel Mar 03 '10 at 21:45
  • 1
    If two machines try to publish the same hostname (or any other name), there's a resolution mechanism defined as part of the protocol. One gets the original name, say "foo", and the other gets "foo-1". – Peter Westlake Mar 05 '10 at 16:57
1

An IP address doesn't tell you anything about the device. As well as machines setting host names as Kamil explained, printers and scanners and cameras and storage devices can all have helpful names built in. So you might see names like "Inkjet Printer Model 1234" and "Digital Camera XYZ". Deciding which one will print your document is much easier than trying to choose between 192.168.1.11 and 192.168.1.12!

If you have more than one of a device, you can very often change the names, but for something like a printer, the name that's set at the factory is usually good enough. So to answer the second part of your question, for many devices, the names are assigned by being burned into ROM at the factory.

Peter Westlake
  • 806
  • 2
  • 6
  • 17
  • Should be pointed out that the meaningful name is not necessarily the hostname. Some devices publish a name like "Inkejt Printer Model 1234 named " in case there are multiples of them on the network. – Kamil Kisiel Mar 05 '10 at 22:52