Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am working on linux environment and c language. I can not use python,perl,PHP and apache. What my exact need is I want to give a same host name to each device connected in the network. I know that we can't give same host names to all the devices. But Can it be done through cnmae?

For example:

There are 3 devices connected in a local network Device-A,Device-B and Device-C. The IP address will be, and Each device contain one httpd server from which I can access the web pages of that device in my PC. Let say if I type in the browser then it will open the web page of that device. Now My PC is directly connected to one device. And I will write device.local in the browser so it should open local device's web page. Is it possible? If yes then how?

Research which I have made:

  1. I have used dnsmasq but it fails to run. I have just turned on the cname in dnsmasq.conf file. It gives me following error: dnsmasq: bad option at line 529 of /etc/dnsmasq.conf
  2. I am using avahi for zero conf networking. In that avahi-daemon is there. So I can give the host name to each device. But it gives the name like device.local,device-2.local and device-3.local. After that I have followed this link also but it did not work for me.


Thank in advance. It is really important for me to solve this problem.

share|improve this question

2 Answers 2

You can use Round Robin DNS to make a single DNS entry give out one IP address in a pool of multiple IP addresses. So a query for device.local will reply with, and then the next query for device.local will be replied to with and etc. until the pool of addresses is finished. Once the pool of addresses has been given out in succession, the DNS server will start back at the top of the list of IP addresses and give them out in the same order again. It's a poor man's load balancing, in essence.

A CNAME record is not what you are looking for. Stop using them - you want to use A records and round robin.

Let say I have connected my 1st laptop to Device-A and 2nd laptop to Device-B. In browser of both the laptops I write device.local. Then In first laptop it should show me web page of Device-A and in the second laptop it should show me web page of Device-B. Is it possible?

Now that's a different scenario. In the first scenario I talked about above, all devices (deviceA, deviceB, deviceC and any PCs / laptops that want to access them) are all on the same network, or at least have a clear route to deviceA, B and C.

If you directly connect a laptop to DeviceA, but have no ability to connect to Device B or C. You have two problems:

  1. You have no access to the DNS server that hosts the round robin records. Your only option is to then host a DNS server service of some kind on the laptop itself or use gulp the hosts file.
  2. If you do host the round robin DNS service on your laptop, you have only a fraction of a chance of having the right IP address given to you. If DeviceC's IP address is next in the round robin queue, but you're only connected to DeviceA, then you're out of luck.

If direct connection between two devices is necessary, you're only hope is broadcast name resolution like what SAMBA / NetBIOS provides. However, that doesn't work across subnets (without great pain and suffering) and certainly doesn't work across public networks like Yon Grande Internet.

At this point, I believe you need to seriously consider:

  1. What you are trying to engineer
  2. Why you are trying to engineer it this way
  3. The purpose and limitations of the protocols and standards involved. (Namely DNS and name resolution in general)
share|improve this answer
Let say I have connected my 1st laptop to Device-A and 2nd laptop to Device-B. In browser of both the laptops I write device.local. Then In first laptop it should show me web page of Device-A and in the second laptop it should show me web page of Device-B. Is it possible? –  Malay Mar 31 '13 at 7:21
in which case, you're better off using the hosts.txt file –  Journeyman Geek Mar 31 '13 at 7:28
@Malay No - that's a different scenario altogether. I've updated my answer. –  Wesley Mar 31 '13 at 7:33
I am using zero-conf(avahi) network for the devices. The device does not have any kind of display on it so it can not show the IP address of its own. Now Let say there are 3 devices in a network and also my laptop. I turned on the network and device will get the IP addresses by avahi. Now I want to know the ip address of all the devices. Laptop is connected to device-A. So Device-A would be local to that laptop.I don't want to use any kind of softwares like angry-ip-scanner. –  Malay Mar 31 '13 at 7:46
In my previous comment I said that laptops are directly connected to the device. Here let me clarify that the device which I am using has two ethernet ports. so they can connect to other device also and also to the PC. So all the devices will be in the network with laptops. –  Malay Mar 31 '13 at 7:50

You're using the totally wrong approach. You want each device to resolve names differently - the whole point of DNS is not to have different devices resolve names seperately. You'd either want a different DNS server per device, which means having a local DNS server set up per machine, or... the smart answer, just use the hosts file for the system itself, which would be simpler.

share|improve this answer
Can I write same host name for all the devices in hosts file? –  Malay Mar 31 '13 at 8:50
Should I explain it again? –  Malay Mar 31 '13 at 9:00
No, you wouldn't be able to do that. –  Journeyman Geek Mar 31 '13 at 9:35
OK.Thanks For helping me. –  Malay Mar 31 '13 at 10:40

Your Answer


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.