I just started with HassOS today, after reading several articles etc, as I need to monitor my power consuption, due to high amount of power usage and we don’t know where it comes from, so Idea was to add some Shelly plus 1PM to our wireing and put it all together in HA.
As I said I started today and had to learn “the hard way” that IP configuration is not as trivial as with a normal raspian, as I use a RPI 3+B for my setup on an A2 SD card (plan to move to ssd later)
I have monitor and keyboard connected and no ethernet connection, as I used to CONFIG folder to set the main settings for wlan0 prior to the first boot.
I got the inital IP of an IP pool from my DHCP. As I wanted to have a non-pool address out of another network in my house (special encapsulated network only for IoT devices) I had set a static ip for the wlan0 mac address in my DHCP, this is how I handle it with all my different PI projects.
Get dynamic IP → Add MAC to static list → reboot PI to get new IP.
Unfortunately this does not work on HassOS. I always get the same “old” pool address assigned.
I tried reboots, nmcli con down and up and dhcliend -r. Nothing worked.
If the nmcli con down was executed, nmcli dev show wlan0 shows no IP associated, as soon as I up that connection it gets the old IP assigned.
Is there any special command that forces that connection to receive a new IP from the DHCP, I’m not that familiar with nmcli yet and most sources I found just stated “con down and con up” to force a new DHCP lease.
HassOS ver 7.6 core version 2022.4.7
Best regards
im not familiar with nmcli, thou in ha-cli there is a network command, and following commands like update
(i.e … net up -h … gives you -help upon flags i.e --ipv4-method (static-auto-disabled)
PS: thou this is settings for the interface, NOT the wlan0 (which is the Routers name for “some(no named)” device)
PS: im pretty sure there also are --help -h or so, in nmcli
EDI2: a simple google search reveals this https://www.google.com/search?client=firefox-b-d&q=nmcli+commands
Its actually the normal way for dhcp leasing you are describing.
When a reconnection to a network occur, then the dhcp client will request a new DHCP lease for an ip address.
If it has been connected to the network before, this request will be added with a request to get the same ip address as before.
DHCP servers will usually honor that request and reply with a lease for that IP address, but DHCP servers also run a list of leased IP addresses and which MAC addresses that hold those leases.
It uses this list to hand out the same IP address to the same device, so the device do not even have to request it.
The DHCP lease time on the DHCP server sets the time an IP address is reserved for a MAC address on a device. In that period other devices requesting a DHCP lease will not be able to get this IP address, not even if there is none other available.
When the DHCP lease time has expired, then the IP address can be handed out again, but the DHCP server will usually hand out the unsud IP addresses to new MAC addresses first and then switch to handing out oldest used IP address ffirst newer ones.
In other words the system is rigged towards you always getting the same IP address, if at all possible.
if “Add MAC to static list” means you have added the MAC address to your DHCP servers static list, then the DHCP server should respond with a refusal when HA request the same address as before.
If this does not occur, then you might have made and error in adding the MAC address to your DHCP server.
I have seen DHCP servers that was handle MAC addresses as different if the static list contained capital letters and the DHCP request was in non-capital letters, so be sure to type it in exactly as the DHCP server sees the lease on a dynamic IP address.
And if in doubt with the commands, then reboot the entire host.
I found the issue in my own “complex” network setup, as the connection was established via the AP, which has only 2 different LANs to be configured and I use LAN A for the connection of the IoT WLAN network. The related cable from LAN A on the AP is connected on Port1 on my Router, but the Router is configured to serve Lan1 on Port 1 only. After adding LAN 2 on the router on Port1 (which is different from LANB on the AP, as the LAN B on the AP equals and connects to the LAN 4 (Port5) on my router). I still get a dynamic IP of Lan 1 range on the first boot up of a device, but I can set the static entry on my DHCP and after reboot the device get the correct IP.
So fault on my side apologies for wasting everyones time