advertisement


Router question

ks.234

Half way to Infinity
The raspberry pi I have in my lounge, set up for streaming radio and music files on SSD, keeps changing IP address i.e. changed again today, last time was a few months ago. I have reset the router recently, is this why, if so, why is it only the pi in the lounge and not the ones in the office and workshop? Why not other devices? Not a problem really, but is this normal?

PS Router is latest BT smart hub 2 thing
 
Last edited:
Normal.

You often can set a static IP on the device, or even better let devices use DHCP (automatically assigned an IP by the router) then get the router to assign the device a static IP.

On my router (Asus RT-AC66U) it looks like this:

NkmthDZ.png
 
Yes, it's normal for IP addresses in a domestic setup to change, especially if your router restarts. You can make the addresses static in various ways if this is a problem.
 
I don't know which router you have but there is usually a place where you can bind (lock, associate etc) an IP address that has been assigned via DHCP permanently to the MAC address of your Pi. What this means is that every time the Pi fires up and requests an IP address via DHCP it will always be allocated the same one even through a router reboot.

There is no need to muck around with static IP addresses. BTW LANs work using MAC addresses as each LAN adapter has a globally unique address.

Also FYI IP addresses are leased for a given time and this is useful for things like 'hot desking' where an address that hasn't been used for a while goes back into the pool for someone else to use.

Cheers,

DV
 
The raspberry pi I have in my lounge, set up for streaming radio and music files on SSD, keeps changing IP address i.e. changed again today, last time was a few months ago. I have reset the router recently, is this why, if so, why is it only the pi in the lounge and not the ones in the office and workshop? Why not other devices? Not a problem really, but is this normal?

PS Router is latest BT smart hub 2 thing
Has this device been given a shorted lease time that other things on your network? I can't imagine why this would happen, but if so, you can probably give it a longer lease. Then again, if you are not having discovery problems, it could be a case of 'if it ain't broke, don't fix it!'
 
Has this device been given a shorted lease time that other things on your network? I can't imagine why this would happen, but if so, you can probably give it a longer lease. Then again, if you are not having discovery problems, it could be a case of 'if it ain't broke, don't fix it!'

Yes, definitely agree with the ‘if it aint broke...’ thought, but I am just curious to know how these things work. Will probably try suggestion of ’Strictly’ and others, but again out of curiosity rather than necessity.
 
Just out of interest, why do you need it to have a fixed IP address?

Modern OSes, and modern hosts (like the Pi) understand a thing called mDNS (multicast DNS) which basically means that they are waiting for a DNS request, and will respond with their IP address if you ask them...

So, assuming you haven't changed your raspberry pi hostname, try 'ping raspberrypi.local' from a computer, and see if it resolves? If you have multiple pis on your network with that name, you'll basically get a response from one of them, which may not be the one you want. To resolve that, change the hostname on the pi, and then it'll have a unique name you can ping. At that point, use that domain name to reach it, rather than relying on an IP address as you are discovering they don't scale well if you are managing a largish network.

https://en.wikipedia.org/wiki/.local
https://thepihut.com/blogs/raspberry-pi-tutorials/19668676-renaming-your-raspberry-pi-the-hostname
 
Oh, and as for why the address has changed, if you reboot your router, you loose the assignments (as far as it is concerned), and so when a new device asked for an address, it might be allocated one that another device on the network thinks it already has. At this point, the host re-requests via DHCP and it will get a new address, so basically there's a confusing bit when multiple devices think they have the same IP but it sorts itself out in the end (with some devices shuffling).
 
Rebooting the router shouldn't cock up any addresses issued by DHCP. Renewal etc is done from the client and in most cases will renew the same address as and when,dependent on the lease time. With a typical 254 addresses available from a typical router conflicts shouldn't be an issue in a domestic property and nor should a short lease time be needed to get addresses back in the pool.
 
Rebooting the router shouldn't cock up any addresses issued by DHCP. Renewal etc is done from the client and in most cases will renew the same address as and when,dependent on the lease time.

The client requests the same address it used to have, but the DHCP server decides if it honours the request or not. It might have given the address to some other device during the time the client was inactive, and might just respond with "sorry, the address you wanted is not available, here is a new one".
 
Normally it doesn't matter if the client is inactive, the DHCP server won't give away an IP address that has an unexpired lease. In DHCP the client will actually request the lease is renewed at half of what the lease time is set to not when it is expiring.

An issue I've seen before is that when the DHCP pool gets small some servers will send ARP requests to the clients every minute or so, if they don't respond the lease gets released and allocated to another client.
 
The client requests the same address it used to have, but the DHCP server decides if it honours the request or not. It might have given the address to some other device during the time the client was inactive, and might just respond with "sorry, the address you wanted is not available, here is a new one".

Yes I mentioned lease time.....
 
Normally it doesn't matter if the client is inactive, the DHCP server won't give away an IP address that has an unexpired lease. In DHCP the client will actually request the lease is renewed at half of what the lease time is set to.

Yes, the problem comes if the device is powered off while the lease expires - that is why short lease times can be a bad idea.
 
It's also worth noting that ISP routers are utter bobbins for anything more than the most basic functions. Looks like the BT smart/home hub has a lot of complaints about DHCP over on the BT support forums.

If you ever want to do Mac reservation, custom DNS or DynDNS etc it's well worth getting a 3rd party router instead and putting the ISP one into modem only mode (which is not possible with BT by the looks of it)
 
As I said, no, you're better off just keeping things dynamic, and using mDNS requests to determine addresses between machines when you want to reach them from each other. This is a much better place to be that relying (and remembering) actual addresses. Just try it on your existing network with your existing setup and see if it works
 
As others have said, this is the normal working of DHCP. If you don't need a static IP address for your Pi, leave it alone, as it means you can pop the Pi into most networks and it will connect.

Static IP addresses are normally needed for servers, so that other computers (the clients) can easily connect to them by using that address. If you really need to give the Pi a static IP, the advice above is all good.

(Yes, this is an oversimplification, but I think it is the appropriate level of detail here.)

Kind regards

- Garry
 


advertisement


Back
Top