How to change IP adresse in CLI

This is the heavily missed context…

I am developer with experience in Linux, Docker, Python and whatnot and it’s not obvious to my how I can get to the host terminal after reaching the HA> prompt after booting.

6 Likes

Yes, that login command is not listed anywhere. It was present the early days before they changed the OS interface, but still works. Maybe someday will be depreciated, but at this moment it works and let you use docker as usual from the root prompt.

1 Like

I was sure I read it somewhere on the official documentations, and you are right - couldn’t find it now.

The only reference I could find about this login is at the bottom of this page… not obvious at all:

Hello there,

I switched network providers too and I can’t sign into the web UI either.
Did you get yours to work, if so what did you do.

Thanks!

I have had a very hard time getting this far with HA, but I still do not get what you are showing. My nmcli does not understand set and I do not see a ready replacement.Have tried numerous versions of HA with no joy at all.This new way is not very good?First the dictatorial removal of YAML now a startup that is incomprehensible not an auspicious follow up. Is there complete help for this?

Edmond

1 Like

NOTE: This post was written several years ago and outlines a way to set a static IP using low level tools. If your network uses DHCP to assign IP addresses (if you aren’t sure, it does) then please scroll down to this post that describes a newer method.

You want to:

  1. Be connected to the HA CLI, you should see an ha> prompt
  2. Run ‘login’, you should now see a # prompt
  3. Run ‘nmcli connection show’ to see your list of connections and choose which one you intend to edit. In my install there was only one listed, “HassOS default”
  4. Run ‘nmcli con edit “HassOS default”’ (or whatever your connection is), you should now have an nmcli> prompt
  5. Once in the nmcli prompt, run these commands filling in whatever your network details are:

nmcli> set ipv4.addresses 192.168.1.10/24
Do you also want to set ‘ipv4.method’ to ‘manual’? [yes]: yes
nmcli> set ipv4.dns 1.1.1.1
nmcli> set ipv4.gateway 192.168.1.1
nmcli> save
nmcli> quit

  1. Exit the login prompt (run ‘exit’)
  2. At the ha> prompt, run ‘ho reboot’
31 Likes

Just to add to this, if one has two connection profiles, for example this is how mine seems to be setup:

$nmcli con show
NAME               UUID                                  TYPE      DEVICE 
Supervisor enp0s3  c14e9fbc-98dc-49e0-b65e-c39d18abdef9  ethernet  enp0s3 
HassOS default     f62bf7c2-e565-49ff-bbfc-a4cf791e6add  ethernet  --     

only one connection profile can be active at a time, so pick the one that has a device listed under DEVICE (i.e. pick “Supervisor enp0s3”)

2 Likes

thanks for the education, ive become quite proficient with NMCLI now :smiley:

I found a similar command (much differnet syntax) from the ha> CLI that you can use to check and change your network settings:

ha > network info
this will provide information aboiut your networ settings.

HA> network update (followed by your ethernet adaptor name and an IPV$ command)

for example, this command will force the interface to automatic DHCP for ipv4 and ipv6
ha> network update enp2s0 --ipv4-method aut0 --ipv6-method auto

20 Likes

Thank you for posting this. Saved me a ton when I switched to a mesh router.

I also figured out that:
nmcli is not available with the official add-on “Terminal & SSH”
nmcli is available with the HAC Add-on “SSH & Web Terminal”

1 Like

Guys you saved me today. Yesterday after a power outage the Home Assistant OS wasn’t coming up anymore. No IP no matter what. It’s running on Odroid N2+.

I found out that ipv4.method was disabled. So using nmcli I brought it back to life. Awesome.

1 Like

@phobiac your the difference between someone who wants to help and someone that … your write up was soooo helpful and to the point. There are so many posts looking for this info and definitly HA needs to do work in this area.
If you install your HA on a Raspberrypi you should be able to simply config the net without having to connect to a live network that has a dhcp server running…wth.
In my case I build my system got it all configured and restored my backup from my VM. My last step before putting it away was to configure the Wifi. I setup the WIFI and then disabled the lan…Bam, I forgot to enable the wifi and now the system is bricked. and I did not know how to get out of docker to the OS…
Thanks again!!!

2 Likes

Glad I could be of service! Funny enough, I ran into this exact issue again just a few weeks ago and ended up finding this thread and my own post… So like many lessons with documentation, I ultimately helped future me out too.

1 Like

I would say that using DHCP for anything other than guest devices is a mistake and that 99% of people using Home Assistant do need to change the IP address. Especially if you have anything more than just a consumer router which it seems that most people using Home Assistant probably do given the necessity for well above normie technical skill required to use it.

1 Like

I mean, you might want to look at the forums again - have a count how many people are asking for YAML help - despite the very YAML they are needing help with, either already being able via a forum search, or it’s actually documented on the Home Assistant documentation site.

68% of people are running Home Assistant OS, and almost half of people are running on a Raspberry Pi 3 or 4. I’m not sure why you believe that Home Assistant is only used by people with deep technical knowledge.

Regardless - ALL consumer routers, allow you to reserve or pin an IP address that a device has been provided by DHCP, obviously they have to provide that ability - because otherwise it would impossible to do port forwarding.

The same applies if you are not using a consumer router, and in fact if you are not using consumer router - then you can reserve an IP address by MAC address - and that gives you the ability to decide your own IP address to provide to the device.

In neither of these options have we needed to actually give the device itself a static IP address.

If you do need to give the device an IP address though - since you have decided to respond to a post that is now a YEAR old. You can in fact do it directly from the settings page in the Home Assistant GUI

2 Likes

That’s what I was going to ask about. For less technically inclined people, there is no need to use CLI prompt anymore, right?

Nope, if you can reach the web interface then you can assign an IP Address from the web interface.

1 Like

Thanks. I have a masters in EE and I didn’t know this. @k8gg: No need to be condescending to newbies who need step by step instructions.

1 Like

Thank you @tom_l !!! I really appreciate the instructions.

1 Like

After 2 days off-line I found @odiaz59 procedure and this works fine.

To change your home assistant ip address:

ha> network info

look for interface to grab the name

ha > network update enp0s3 --ipu4-address 192.168.1.45/24

this takes about 20 seconds

Command completed successfully.

5 Likes