LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-01-2011, 09:07 PM   #1
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Rep: Reputation: 4
Question DNSMASQ how to automatically add hostnames


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.
 
Old 01-02-2011, 03:37 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 01-02-2011, 07:22 PM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by Axel van Moorsel View Post
... How do I configure DNSMASQ so that i can use hostnames for computers who get their IP addresses from DHCP.
From http://www.thekelleys.org.uk/dnsmasq/doc.html:
Quote:
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/.
 
Old 01-06-2011, 05:16 AM   #4
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Original Poster
Rep: Reputation: 4
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.
 
Old 01-06-2011, 05:18 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Oh, you weren't using DNS and DHCP within dnsmasq?? You said you wanted it to do DNS in the first post?
 
Old 01-06-2011, 06:17 AM   #6
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Original Poster
Rep: Reputation: 4
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.

Thanks for your support
 
Old 01-12-2011, 08:42 AM   #7
fgumpquad
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
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?
 
Old 01-12-2011, 09:25 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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?
 
Old 01-13-2011, 07:39 AM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Is there a difference between the DHCP clients on the Ubuntu & CentOS machines?

Or their configurations?
 
Old 01-14-2011, 11:32 AM   #10
fgumpquad
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
The DHCP client on Ubuntu 10.10:
Internet Systems Consortium DHCP Client V3.1.3

The DHCP client on CentOS 5.5:
Internet Systems Consortium DHCP Client V3.0.5-RedHat

Doesn't seem like there would be much of a difference...?
 
Old 01-15-2011, 08:55 AM   #11
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
How about the configuration files?

Hint: use "Code:" tags or a pastebin to post them.
 
Old 01-18-2011, 12:36 PM   #12
fgumpquad
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
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:

request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope, interface-mtu, ntp-servers;
require domain-name;

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).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically add to iptables? hboosh Linux - Networking 2 12-23-2009 03:00 AM
vim add # automatically noir911 Linux - Software 11 09-13-2006 10:56 PM
automatically add route on boot? Loz Linux - Networking 1 11-22-2004 11:56 PM
Gnome 2.6: Automatically add games? technopasta Linux - Games 1 04-21-2004 08:35 PM
Script thats add users automatically embalmedlenin *BSD 1 09-14-2003 04:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration