1

I've got a 3b+ which I have successfully attached to my WiFi and I can access internet etc fine. I want to set the IP to be static as I am running it headless. I went to my router to do this and it does not appear on DHCP client list. I know it is on http://192.168.1.16 as I am accessing it via VNC. When I scan the network using Lanscan on my Mac I can see it absolutely fine. Obviously I can set the IP manually on the Pi but I would prefer to do it via the router. Any idea why it might not be showing up?

5 Answers5

4

To answer your question:

Any idea why it might not be showing up?

A static ip address is a static ip address is a static ip address. It is not manged by any DHCP server, so you will not find a static ip address in its lease cache. That's by definition. You have to do everything by hand, define DNS server and gateway and other things you normally get from the DHCP server and you have to take attention that it does not conflict with the same ip address given by the DHCP server to another device. That's also the reason not to use static ip addresses for simple clients.

Ingo
  • 40,606
  • 15
  • 76
  • 189
1

Sometimes I read a question and consider what a person is trying to do and why... and consider if there might be another way to solve the problem. This is one of those ... so this isn't a direct answer to your specific question, but possibly another strategy that will meet your needs.

I don't know that anyone will be able to tell you why your DHCP server (which sounds like it's on your router) isn't listing your Raspberry Pi's IP address lease. And that's not really a Raspberry Pi question ... it's more of a question about your DHCP server (which is probably really a question about your router).

But there might be another strategy that will fit your needs.

Multicast DNS

Both your Raspberry Pi and your Mac support mDNS. This is a protocol that's just built-in (you don't have to do anything) and it's a zero-configuration protocol (there are no files to maintain, nothing to turn on, etc. it "just works" as long as your OS has the feature). It let's computers on a network resolve other computers on that same subnet as if you were running an DNS server ... but without actually have to use a DNS server.

The implication here is that you don't need to worry about an IP address changing because the hostname will always work to resolve the host -- even if the IP address does change.

You need to know the hostname of the Pi (but only it's name). e.g. I have a Pi named "tims-raspi-8gb". mDNS will be used as long as you use the ".local" suffix when referring to the machine by name. e.g.:

tim@timsimac:~$ ping tims-raspi-8gb
ping: cannot resolve tims-raspi-8gb: Unknown host

tim@timsimac:~$ ping tims-raspi-8gb.local
PING tims-raspi-8gb.local (192.168.1.36): 56 data bytes
64 bytes from 192.168.1.36: icmp_seq=0 ttl=64 time=0.761 ms
64 bytes from 192.168.1.36: icmp_seq=1 ttl=64 time=0.389 ms

Notice in the first case when I omit the ".local" it gives me a "Unknown host" result. But in the second attempt when I do use the ".local" domain it resolves the host and "just works" even though I didn't actually know the IP address nor was this listed in my /etc/hosts file, etc.

mDNS uses multi-cast (as the name implies). Any host on the network that supports the protocol (which is most operating systems these days) is listening for the requests.

The client sends out a multi-cast request to everyone who is listening (all hosts running mDNS are listening) and basically asks who has that hostname. All the hosts hear the question, but all the hosts who aren't the host you want ignore it. The host that is the host you want will respond back with the info -- and now the IP address is resolved.

This works in any field that would accept a hostname or IP address. You can use it on the command line. You can use it in a web browser. You can use it when configuring software, etc. etc. It "just works".

There is one main caveat... this multi-cast request will NOT be copied over subnet boundaries. In order for this to work, all the hosts have to be on the same network subnet. If you have a home or office network that is divided into multiple subnets, this wont work across subnet boundaries. Also if you set up a VPN to remotely access your network, the VPN clients are generally treated as if they are on a different subnet ... so it wont work there either.

If you use Windows this gets a bit more nuanced... there is Windows support for mDNS but it isn't necessarily on by default. Windows users may have to test it and there is documentation on how to enable it -- but that's off-topic so I wont go into those details.

Tim Campbell
  • 885
  • 5
  • 16
1

I still fail to understand why Pi users want to set Static IP addresses.
If you really NEED a consistent address it is far better to reserve one on your router. (This also avoids the common errors.)

If you REALLY want to set a Static IP addresses AND have your router aware of it you can use the request or inform directive.

Extract from the dhcpcd man page:-

request [address]
Request the address in the DHCP DISCOVER message. There is no guarantee this is the address the DHCP server will actually give. If no address is given then the first address currently assigned to the interface is used.

inform [address[/cidr[/broadcast_address]]]
Behaves like request as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST. This does not get a lease as such, just notifies the DHCP server of the address in use. You should also include the optional cidr network number in case the address is not already configured on the interface. dhcpcd remains running and pretends it has an infinite lease. dhcpcd will not de-configure the interface when it exits. If dhcpcd fails to contact a DHCP server then it returns a failure instead of falling back on IPv4LL.

Seamus
  • 18,728
  • 2
  • 27
  • 57
Milliways
  • 54,718
  • 26
  • 92
  • 182
1

There is ambiguity in your question - the sequence of events is important, but unclear: You said, "I went to my router to do this and it does not appear on DHCP client list." This implies that your RPi was - at this time - using a DHCP-assigned address. However, the fact that your IP address did not appear in the "client list" (lease table?) contradicts your statement. OTOH, if you had already assigned a static IP in dhcpcd.conf before you "went to your router", that would explain why you didn't see it. Your RPi could have appeared to be properly configured due to the "magic" of zero-configuration networking on the RPi.

And so your question seems to be, "If I use the static value option in dhcpcd.conf, why does my RPi NOT appear in the "client list" (DHCP lease table)?

The answer is that it's not supposed to show up; it does not have a leased IP - it's got a static IP. If you want a host with a static IP to "show up" in the DHCP server's "client list" (or DHCP lease table), then the only way that's going to happen is for you to add it in manually. Entering a static IP host to the DHCP server is sometimes referred to as "reserving an IP address". It also requires that the static IP address be outside the "pool" of dynamic IP addresses the DHCP server draws from to assign to its real clients. A static IP host is actually not a client (of the DHCP server) at all. In fact, using the static value configuration means that your RPi will never exchange messages with the DHCP server; they are incommunicado iaw the DHCP standards!

If all of this sounds confusing, that may be a clear signal that you should probably not be using the static value option in dhcpcd.conf. Your RPi will run headless perfectly fine - with no loss of network functionality - using a dynamic IP address. The dynamic, DHCP-assigned IP also has the advantage of being the easiest solution!

But if you feel you need a static (unchanging) IP address for your RPi, you have 3 options:

  1. Use the static value option in dhcpcd.conf, and manually add the "IP reservation" discussed above.

  2. Use the request X.X.X.X/CIDR option in dhcpcd.conf. Technically this is not a static IP, but if you choose an IP that is not in active use, it may well be an unchanging IP address.

  3. Use the inform X.X.X.X/CIDR option in dhcpcd.conf. If you do this, you will get a true static IP with the benefit that the DHCP server will supply your DNS and default route/gateway addresses. You must also take the following steps:

    • Choose an IP that is not within the DHCP server's dynamic "address pool".

    • Add the "IP reservation" to the DHCP server as discussed above.

    • You should be aware of the bug in the version of dhcpcd distributed through RPi's apt repo. A patch for this bug was submitted to the dhcpcd upstream source on Mar 31, 2022, but as of this writing the Raspberry Pi organization has not released an update. If you want to apply the patch yourself, see this how-to.

In Summary:

If you use the request X.X.X.X/CIDR option in /etc/dhcpcd.conf, you can have an unchanging IP address with a minimum of effort. However, you should realize this is not necessary for a fully-functional headless RPi.

REVISED 6/2/2022.

Seamus
  • 18,728
  • 2
  • 27
  • 57
0

I think you have probably already set the IP manually on the RPi, then are looking at a list of addresses that have been assigned by the router's DHCP server. If you set a static IP on the RPi, it doesn't use the router's DHCP server. Depending on router model, you may find another list of 'IP addresses on local network that have been used recently' and that would include the one that your RPi has assigned to itself. (On my router, I can see such addresses for ethernet wired connections, but not for WiFi connections).

If you instead tell your router's DHCP server to 'always give the following address to my RPi' (also known as "reserve" the IP address) you will see it on the list. That is probably a better way to assign a static IP address.