How to change IP address in CLI

I guess its an old statement, but if you look in a bigger picture. Cloud providers are using endless leasetime DHCP. Its just simpler to handle the IP outside of the OS.

Your statement is more true like in the 1990s, early 2000s where CPU and RAM was limited, but today its not the case anymore.

Just handle (almost) everything using DHCP.

HI I successfully updated my ip address by writing in the CLI:

network info 

to gather infos about the interface’s name (I discovered my interface was different from eth0)
then

network update eth0 --ipv4-method auto

this resolved the stupid decision to assign a manual ip and not checking twice

2 Likes

Simple example. My home network contains about a hundred devices. It’s a large area and several buildings connected by cable and radio bridges. Of course I have a lot of wifi access points, some of which are routers set up as access points. One of these access points went crazy (maybe it was updated incorrectly or some other failure). It so happened that during a scheduled reboot of the central router, there was no electricity in part of the buildings at night. When it appeared, this crazy access point turned on its own dhcp server, distributed its addresses in its segment and decided that it was the main gateway. As a result, a whole segment of the network was completely lost to “smart devices” even though everything looked like it was working. Thus, all dhcp-dependent devices were affected by this failure. At that moment only those devices in which ip, gateway and dns were manually set, worked correctly. Of course, this is not a normal situation, and this “too smart” router went to the local flea market, and its place was taken by one that will not be able to do anything on its own.
I’m sure that the use of dhcp is applicable to such devices as smartphones, tablets, TVs and other devices for which ip address is not important in most cases. Well, or those in which it is impossible to set the address manually (the same sensors and tuya outlets). In such cases you need to assign ip addresses in the router with binding to mac. But such things as servers should be configured manually. And the range available for dhcp should be limited to a small and reasonably sufficient segment.

I was looking everywhere for exactly this. I was caught in a terrible loop where HA wouldn’t get an IP address so it couldn’t reach the time server, so it didn’t boot properly, etc.

TL;DR you’re a hero

1 Like

Thanks for this advice!

I managed to change my IP address via CLI using the following commands:

  1. network info to find the correct network adapter and see your current IP address set for HAOS
  2. network update eno1 --ipv4-method auto --ipv6-method disabled (“eno1” needs to be replaced by your network adapter)
  3. network update eno1 --ipv4-gateway 192.168.x.x (“eno1” needs to be replaced by your network adapter, “x” needs to be replaced by your IP gateway, probably router IP)

After doing this, my Fritz!Box auto-assigned showed an IP address for Home Assistant again.

7 Likes

Yeyieh thanks

Thank you for providing a COMPLETE answer. It gets frustrating for answers to be given with incomplete context.

Hi,

my first attempt do move HA from my default LAN to a VLAN in Unifi did not work. Yes, i use a static IP:

Can somebody help which steps in which order are required to move HA to a VLAN? Is there something specific to take care?

This is real magic. I was trying to solve the issue for last three hours with no luck. Tried all options nothing has worked. Finally with just two commands, able to resolve the issue. Thanks a ton for this instruction.

4 Plus hours of struggling and finding nothing at all, and your post saved the day, and my HA instance. Thank God for you!!

cheers , had it set up in proxmox , then installed pfsense , worked perfect cheers fella

Quite. Help is only help if it helps and I often find once I can’t resolve something from the GUI (where ordinary people can explore and learn), and have to drop to the CLI where I’m often in a whole world of hurt and frustration as I’m not a guru don’t speak their often highly abbreviated and full of assumption ‘help’ language. ;-(

‘Just type xyz’ when there might be 10 steps you have to have in place before you can do that.

Like whilst suggesting a new HA owner (Generic X64-86 HAOS) change his IP from DHCP to static, we ended up with a /32 netmask and so have locked ourselves out.

I have been trying to see what you might need to do to get that sorted from the CLI (via my own Odroid N2+ HAOS install) but nothing seems to work (the tips here seem to have got the closest) and so I think we are just going to re-flash the m.2 drive with a fresh HA and try changing the IP address again, before even restoring the one backup he took locally.

Mucking about with different SSH / Terminal tools, SSH keys, CLI logins and incantations that don’t seem to follow the guides …

Why couldn’t there be a HA splash screen terminal / menu driven way of setting such things, like you see of the RPi (Raspi-config or whatever it’s called)?

Except when the IP is not assigned you cannot reach the web interface, that’s why so many people are asking how to do it.

I agree that a “Rapspi config” would be helpful. But until then the only way to we have is to proceed with what we have.
If you have set up SSH on the Home Assistant host. Can you connect using “Putty” or use a terminal to get to the HA host? My answer below is only what I did to solve my problem remotely using SSH to connect to the HA host.

If the answer is “Yes” then this is how I was able to fix my IP address issue. Replace the “xxx’s” with your information

login as: root
[email protected].xxx.xxx’s password:xxxxxxxx
ha network info
Look for this information
connected: true
enabled: true
interface: end0
ipv4:
address:
- 192.168.xxx.xxx/24
gateway: 192.168.xxx.xxx
method: auto
nameservers:
- 192.168.xxx.xxx
ready: true
ha network update end0 --ipv4-address 192.168.xxx.xxx/24
The 192.168.xxx.xxx/24 above is the new IP address you want Home Assistant to use

Honestly this implies you have a network design flaw. With such network you should not be using these devices as they are not meant to be. 10 years ago when I truly started building the home network I used such devices, but with their limitations I soon moved to dedicated hardware (APs, Routers with no WIFI, etc) as they are more reliable. None of the network devices like to unexpectedly reboot. I made sure proper UPS is installed.

Its much more important to have a reliable DNS/DHCP system than to stick to IPs. Static IP is the old world.

A combination of DHCP and private DNS is especially handy, when you are doing some changes on your network completely remote like moving all cameras to a separate VLAN without actually touching the NVR or camera.