How to change IP adresse in CLI

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

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’
24 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

15 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”

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!!!

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.

3 Likes

Untitled

My connection profile doesnt have a device associated how do i fix that?

Good question. My system automatically set up the profile, so I’m not so sure.

First let’s see what there is (type each of the following):
nmcli connection show - just to verify there are no other profiles.
nmcli device status - to see if there are any interfaces.

If “Supervisor enp11s0” is the only profile, and you have an interface enp11S0, then you may be able to add the interface to the profile using:
nmcli con add con-name "Supervisor enp22s0" ifname enp11s0 type ethernet

Hey Tommy thanks for that,

So it looks like my connection is showing as disconnected when I run the status command:

image

For a little context this is running under ESXi 7.0U2 and had been working successfully for some time. Recently I had issues as Veeam tried to backup the VM (it creates snapshots) and subsequently it wouldn’t boot. I resolved that issue and now I have this one…

I ran the: nmcli con add con-name "Supervisor enp22s0" ifname enp11s0 type ethernet command successfully but it has now created two profiles:

image

Although it looks as if the actual problem is the adapter showing as disconnected.

Sorry, I think I was fiddle-fingering my response and mistyped the profile name.
Since the interface name is shown as enp2s1,
try: nmcli con add con-name "Supervisor enp11s0" ifname enp2s1