[SOLVED] DNSMASQ how to automatically add hostnames
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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 am using DNSMASQ on a Debian 5.0.6. server.
I configured DNSMASQ as DHCP server, and want it to answer local DNS requests. However, I am unable to use hostnames, and am forced to use IP addresses when pinging, opening a ssh shell on a remote server, opening a remote desktop to a windows system etcedtera.
Because I use DHCP, I can not hard code the ip addresses in the hosts file.
How do I configure DNSMASQ so that i can use hostnames for computers who get their IP addresses from DHCP.
To the best of my knowledge this happens by default, so I'd look at seeing what query you are actually sending to the dns service compared to the hostname signed by dhcp. If you use either tcpdump our add the log-queries option to dnsmasq.conf you cash see exactly what it's being requested and how it related. I've recently been caught up in what domain names are added at various parts of the process.
The integrated DHCP server supports static and dynamic DHCP leases ... and the names can specified by each machine or centrally by associating a name with a MAC address in the dnsmasq config file.
Indicates you can do what you want to do. You'll need to fix the IP addresses to the MAC addresses, & therefore to the hostnames
How recently have you read the man page? A quick scan of it indicates that: -G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
may be the option you need.
Warning: I haven't worked w/ dnsmasq for a couple of years & I didn't do a through read of the man page today.
Please read it for yourself, & then ask any specific questions it leaves you w/.
Thanks guys for your replies. Sorry I didn't reply sooner, but I am working on several projects, and this one is not the most important right now.
Somehow the dynamic updates didn't work, so I had to work with IP addresses instead of host-names. This is a minor nuisance for server, which have fixed IP addresses, and just a little less minor for workstations. One of my minor projects is creating some scripts to access some test computers. I created a script to to test if a host is running, if not then start it with wakeonlan, and then use ssh for servers, or vncviewer for workstions to take remote control.
I solved the issue for now by hard coding the IP addresses in DNSMASQ, and in the hosts file on the DNS server, and this works fine. For the few computers I am working now this is an acceptable solution.
Of course, dynamic updates should be used in large networks, but for now I will close this thread, as I have other things on my mind.
I was using DNS with DNSMASQ, and DHCP with dhcp3-server. By now I have removed dhcp3-server, and configured DNSMASQ as DHCP server. This seems to have solved the problem, because now I can ping dhcp-hosts by name. I haven't fully tested it yet, but it seems fine.
One small issue left: the host-name resolution does not work on the DNS server itself. As I probably will never use it on the server itself, I will leave it as it is.
I am trying to do the same thing. I can report the following:
I am running an Ubuntu dnsmasq host supplying DHCP requests and DNS requests to various clients. All clients seem to be getting IP addresses correctly from DHCP server. All UBUNTU clients seem to be registering their hostnames with dnsmasq when they get their IP addresses. However, I have other CentOS clients and they DO NOT register their hostnames with dnsmasq for some reason. I'm really not sure why not, but the whole point is NOT to have to lock in a particular machine with a particular IP address, so we really don't want to have to do this. Any thoughts on the differences between the two Linux OSes?
Clients should not register with a server, that's illogical (And windowsy). If the DHCP dishes out a lease, then it should update the DNS server using tsig etc. As for the difference, I'd guess it is maybe that the hostname is not being provided as part of the DNS request?
Ok, I have it working with CentOS. It seems that CentOS does not include dhclient.conf file out of the box. In that file, it is necessary to make some specifications. This file is included out of the box with an Ubuntu installation. For CentOS, it should be located in /etc/dhclient.conf The line that's necessary is:
send host-name "myHostName";
There are still a few issues, none of which are particularly high priority for me, but I should mention here:
-It appears Fedora does not use dhclient as it's default DHCP client. When I run dhclient on a Fedora 14 server, nothing happens (whereas with Ubuntu and CentOS, it has clear feedback that it is communicating with the DHCP server). Does anyone know what DHCP client Fedora uses and a) if I can change it to dhclient; and/or b) if whatever client it DOES use can send a hostname back to the DNS server upon receipt of new IP address?
-CentOS still does not receive the domain. I use these settings in the dhclient.conf file:
So it should get domain-name, but when I type hostname --fqdn, I still only get the short hostname (myHostName), not my full domain (myHostName.my.domain).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.