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 have some machines on a network. This network has a DHCP server - which I have no control over, and no DNS server, i.e. the DHCP lease refer you to some ISP's server and do not serve IPs for local machine names. I plan to install a dnsmasq to address this issue. However, the machine I'll install the dnsmasq on itself gets its IP via DHCP. Thus, I need other machines to determine, dynamically, what the dnsmasq machine's IP address is.

The solution I thought of is using a DHCP client to get a lease from this dnsmasq server. Now, I can think of two ways this can work:

  1. Each macine M gets its IP from the main DHCP server; on interface up, they run another instance of a DHCP client, this time restricted to making some request, and this is answered by the dnsmasq server. M then take the lease we obtained, not updating the IP, but writing the DHCP to /etc/resolv.conf
  2. Each macine M only uses a DHCP client once, getting a response from the dnsmasq machine; that machine will also run a DHCP proxy, but when returning the reply from the original DHCP server, it will (a) rewrite the lease with itself as the DNS server and (b) write down that M (identified by a MAC) gets some IP x.y.z.w . Assuming it has a MAC-to-name table, this could then dynamically feed the DHCP server.

Are there packages doing this? Is it at all advisable? Which of the two options is better, in your opinion?

Note: Of course the reasonable thing to do in this situation is just set up a DNS centrally which is fed by the central DHCP server; or get a static IP for a DNS server, in which case you can ignore the DNS server entry of the DHCP lease you're getting. But this is not an option for reasons which are irrelevant here. It is impossible to access or control any central behavior or service, not is it possible to obtain a fixed IP address for anything.

share|improve this question

closed as off-topic by Iain, TheCleaner, Jenny D, cole, mdpc Oct 14 '13 at 16:20

  • This question does not appear to be about professional server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

5  
This question appears to be off-topic because the OP has no control or authority over critical infrastructure and services required to do this (correctly). –  Iain Oct 14 '13 at 12:34
    
I agree with @Iain - however, that said if we are talking <20 machines then you could easily assign static IPs to each of them, set their hostnames, DNS servers, etc. and then use a single hosts file copied to each of them. It isn't wonderful, but it would solve the internal DNS "resolution" issue. But again, the real answer is to have control/authority of the infrastructure at hand. –  TheCleaner Oct 14 '13 at 13:26
    
@Iain: With all due respect, you're just trying to force your advice down my throat. I did not ask about doing it the standard and simple way, but about a problem I'm having, seeing how that way is effectively impossible. That does not make it off-topic, merely not to your liking. –  einpoklum Oct 14 '13 at 14:04
2  
@einpoklum: It does make it off topic. Your organisation will have configured their machines in the manner that supports thier policies. You're now trying to circumvent those policies because they do not meet your needs. You don't have the authority to make the necessary changes which makes you an end user. There is so much fail here it is entirely off topic. –  Iain Oct 14 '13 at 14:10
    
@Iain: Where did I say anything about organizational policies? Or about me configuring "their machines"? It seems like you're reading things into my question from your personal experience, and you're closing the question based this scenario you've constructed. I've read the on/off topic description and you're basically accusing me of misusing equipment. –  einpoklum Oct 15 '13 at 9:10

3 Answers 3

I think you are going about this all wrong. Something has to have a fixed address, that's the way that DNS works what you're proposing Heath Robinson would be proud of.

Configure the current DHCP server to act as a DNS server and forwarder as well.


Edit: The correct thing to do here is to speak to the people who control the DHCP server and work with them to get the machines configured how you need them to be configured.

share|improve this answer
    
These people are in a different country and are effectively inaccessible to me. If I could speak to them I'd just get them to install a DNS server... –  einpoklum Oct 14 '13 at 9:00
    
@einpoklum: Although you may not like it, the correct thing to do is to get the people who have control to help you. If you can't do it yourself, get your manager to help - that's their job. Anything else is just going to cause no end of problems. –  Iain Oct 14 '13 at 9:04
    
Iain, I appreciate the advice and I am certainly trying it. However, I need something which works now. –  einpoklum Oct 14 '13 at 9:07

You can do this in IPv6 with route advertisements (RAs cause SLAAC or another mechanism to assign the address and then cause the host to query a DHCPv6 server for options, if the right bits are set). However, in IPv4, unless the DHCP server handed out the address, it cannot hand out any options. Address negotiation is the core feature of DHCPv4; everything else is tacked on.

share|improve this answer
    
Can you please rephrase your answer? I'm not quite following. Anyway, mine is an IPv4-only question. –  einpoklum Oct 14 '13 at 10:52
1  
Yes, I was saying that you can do it in IPv6, but in IPv4, you cannot. DHCP assigns addresses; it sends other information along with the address it assigns, but not without. Statically configured nodes cannot be made to request information from DHCP; the act of querying that information in IPv4 is the same as renewing the address lease, and carries the intrinsic possibility that the address may change. You can approximate what you want with address reservations. –  Falcon Momot Oct 14 '13 at 10:58
    
I know DHCP only sends information with addresses. I'm thinking of using the protocol to get DHCP leases, with dummy addresses, and only take the DNS server name from the lease. Or, alternatively, to proxy the DHCP request then rewrite one of its field on return. –  einpoklum Oct 14 '13 at 13:06

Very simply, use DHCP reservations. Note down the MAC address of the machine you want to run dnsmasq on, then configure your DHCP server to always give a certain IP address to that MAC.

You haven't given any details on what DHCP server you're using (or even if it's Windows or Linux) but here are some guides:

After you have the DHCP reservation set up, just use the IP you reserved in your DHCP's DNS configuration.

A second, completely different (and more standard) approach would be to configure your DNS server manually with a static IP outside of the DHCP scope.

share|improve this answer
    
If you have access to the DHCP server why not just make it a DNS server too ? –  Iain Oct 14 '13 at 7:54
    
Separation and distribution of services is always a good principle to stick to if you can do it. Eliminates the SPOF and makes maintenance easier. I admit that sometimes role/service consolidation is unavoidable, but the OP is on the right lines here. –  Craig Watson Oct 14 '13 at 7:57
    
I doubt it. I suspect the OP has no control over the DHCP server and is trying to work around local polices. Why would you constrict a stack like the OP is proposing is you can trivially change the config of the systems ? –  Iain Oct 14 '13 at 7:59
    
@Iain: Indeed, I have no control over the DHCP server. –  einpoklum Oct 14 '13 at 8:40

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