1

I'm setting up a couple of Raspberry Pi's on my router's DMZ (don't worry all the ports are closed); my router uses DNSMasq for DNS and so I added the MAC addresses; hostnames and IPs of the pi's to the dhcp static leases.

Now that said, I'm only learning to use dhcpcd; I'm used to the old way of using /etc/networking/interfaces to configure ip address assignment.

On the pi's themselves, I've configured them with /etc/dhcpcd.conf as having a static ip address and pointed them at my DNSMasq DNS Server.

It seems a little strange to do this, but is it okay to do so?

This way my pi's get a DNS record (so the devices can find each other) and a static ip address; I suppose I could configure it so that it pulls the IP based on the MAC address using the dhcpcd client.

That said I don't really know how to configure dhcpcd to pull it's ip address from DNSMasq; I'm planning on adding additional DNS records (maybe from /etc/hosts) for the pi's to pick up for separate nginx server blocks, so is it okay to have static IPs configured in dhcpcd while I have static DHCP leases configured? Or is that weird and I shouldn't do that?

1 Answer 1

2

I am a bit confused about your setup. Maybe I am misunderstanding it.

Anyhow, the way it's normally done is to have one central place to configure everything (in your case, that should probably your router).

Then you don't have to care about the configuration of the RaspPi's. In fact, you can configure them identically; all differences will be resolved by the RaspPi's using DHCP.

If you look at dnsmasq's man page, it can read /etc/ethers (man ethers for details) to give each RaspPi a static IP based on the RaspPi's MAC address. It also reads /etc/hosts to provide DNS resolution for those static IP addresses, so you can name your RaspPi's however you want.

If you do it that way, a plain out-of-the-box dhcp client on the RaspPi's should suffice.

You don't need dhcpd anywhere.

Edit

because why would you assign an ip via DHCP when there's already one assigned statically?

Because you don't want to configure each RaspPi separately. "Statically" doesn't mean "locally configured". Statically means "every machine gets always the same IP address". You can do that with DHCP by looking at the MAC address of the machine.

Imagine you had a thousand RaspPi's. Do you manage those individually? No, you manage them in a central location, and keep them otherwise identical.

The reason is I don't know how to set dhcpcd back to go look for an address from dnsmasq.

I don't get why you think you need to run dhcpd on the RaspPi's. If they need to get other information by DHCP, you need a DHCP client, not a DHCP server. If you want to configure each static address for them locally, then you again can do that without a DHCP server.

If you in addition want to configure each DNS name for them locally by running a DHCP server on them, then this is not going to work. (Though you can make it work by running DHCP clients on them, and having them tell the central DHCP server (your router) their hostnames in the DHCP request).

For DNS, you need to have a central server where all the information is.

2
  • I understand why you don't think it makes any sense; because why would you assign an ip via DHCP when there's already one assigned statically? The reason is I don't know how to set dhcpcd back to go look for an address from dnsmasq.
    – leeand00
    Jun 7, 2020 at 21:01
  • 1
    @leeand00 I would look into that first. Get dhcpcd to use the DHCP server again then manage everything via dnsmasq's configuration. Jun 7, 2020 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .