1

I had an issue related to IP change. Is it typical for a Raspberry Pi to randomly change the IP? When I ran the command ifconfig, I noticed that under wlan0 inet, my IP address changed. I was made aware of this when I noticed I couldn't connect via SSH. I'm not sure if this was a result of me touching the wlan0 settings to set power management off and also adding and removing these two lines in the /etc/network/interfaces file:

  1. source-directory /etc/network/interfaces.d
  2. wireless-power off

My ultimate goal before all this happened, was to get the power management setting for Wi-Fi to be permanently off. My Raspberry Pi disconnects from the Wi-Fi network every few days.

Im hoping someone can shed some light on what happened and how to successfully stop the Wi-Fi dropping connection.

2
  • 1
    Unless you provide detail who knows? If you changed /etc/network/interfaces that is probably the cause of any problem you may have.
    – Milliways
    Commented Jun 8, 2019 at 3:43
  • What device is giving the Pi the IP-address (probably the device from your ISP. They probably erroneously call it a router. There will be a router in it, but it will do more e.g. DHCP server)? Commented Jun 8, 2019 at 20:15

1 Answer 1

1

Default config for a Pi is DHCP addressing. The router (or switch) assigning the IP to your Pi will assign one from a pool of addresses with an express lease time set for the IP address it assigned (mapped) to the mac address of your WLAN0 interface.

Think of this IP as "loaned" to you: it's not yours in perpetuity and the address can be chucked back into the pool and reassigned to another host unless you make the ip:mac address mapping persistent in the router (or switch if it's assigning the addresses via DHCP).

A picture of a DYNAMIC DHCP lease from a Mikrotik router shown below. Note the button "Make Static": Clicking this will change the dynamic mapping to be persistent and stop the router from reassigning your IP to other hosts. Another term for this is DHCP reservation. I nail-down all my Pi IPs this way to ensure they live at predictable IP address. You can also change the default lease period to a really long time. In the picture below circled in blue you can see "Expires After" is almost a year ;-). Anyhoo, hope this help you understand the variability in your IP addressing-

Making static DHCP reservations in a Mikrotik

2
  • 1
    Thank you for explaining this @F1Linux ! Appreciate it!
    – wpnewbie
    Commented Jun 8, 2019 at 21:11
  • No prob. In addition to being a Linux Engineer, I'm also a Network Engineer, so I tend to field questions that marry these two disciplines like yours. Glad I could help!
    – F1Linux
    Commented Jun 8, 2019 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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