How to change IP adresse in CLI

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.

4 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

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

1 Like

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.

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