HOWTO: Set Static IP on Raspberry Pi4 wireless with new HassOS Installation 08/2021

Synopsis: How To Configure Static IP on a PI4, using its onboard Wifi adapter, before ever booting to the GUI or using a wired connection. This documentation was written for HA core-2021.8.8.

Why: I was building a dev box out of a spare PI and needed to get it on Wifi, something I would normally not do. All the documentation I found about setting a static IP was for an already installed machine, I wanted to do this as I built the machine, so it came up the first time on my wifi and with the correct IP. I draw heavily from other peoples work, linked within. The reason I’m writing this guide is that it’s 2021, and the latest I could find was from 2018, and a lot has changed since then, so here’s what worked for me.

You will need:

  • Pi4 (I am told a Pi3 will work, but I have not tried this)
  • Some other computer (mac, win, chrome, lin, doesnt matter) with a USB port available.
  • USB stick of any size which you can erase. You won’t need it after the process is complete so don’t go buy one, use anything you have.
  • a random created UUID, created from https://www.uuidgenerator.net/
  1. Using the spare computer, format the USB drive as Fat32, whatever size it is, doesn’t matter, you are only going to put one file on it.
  2. Name this new USB volume CONFIG (all uppercase, no quotes)
  3. In the root of the USB drive, create a directory called network (lower case) and in that directory, create a file called my-network (all lower case no quotes no spaces)
  4. Edit this file with your text editor of choice and if you are doing static wifi, here’s what you need to put in the file:
[connection]
id=your-wifi-ssid
uuid=random-created-uuid-you-just-created
type=802-11-wireless

[802-11-wireless]
mode=infrastructure
ssid=wh
# Uncomment below if your SSID is not broadcasted
#hidden=true

[802-11-wireless-security]
auth-alg=open
key-mgmt=wpa-psk
psk=your-psk-here

[ipv4]
method=manual
address=192.168.86.110/24;192.168.86.1   (use your subnet, mask, and router)
dns=8.8.8.8;8.8.4.4;

[ipv6]
addr-gen-mode=stable-privacy
method=auto
  1. eject and remove the USB stick from your spare PC, put it into the PI, and boot the PI. If all goes well, it will boot, join your network, and be reachable at the IP address you used above.

Once you have successfully booted the PI to HA, then named your HA, signed into it, created your user, etc, you can shut down the PI and remove the USB key. You will not need it again.

The PI is now configured to boot with your new IP information. Reboot the PI.

If the PI didn’t join your Wifi, have a look at the my-network file again, there should be no fancy characters in it, and no extension on the file name. You can change the syntax to use DHCP or in fact a wired static IP via this same method if you like, see the documentation from git listed below.

I drew this information from the following resources, and thanks to all for your work on this magnificent product!

Hope this helps!
-Jim

1 Like

Please remove hass.io from the title, the term has been deprecated for more than a year now.

good catch thanks

Hi there guys. I spent the better part of 4 hours trying to figure out how to connect Home Assistant to a wireless router without having to plug an ethernet cable or fiddle with a USB stick. Jokes on me I know, but I am curious until I am not. Okay so here is what I found out about connecting via the CLI to a wireless router for a Raspberry Pi 4:

  1. Home Assistant CANNOT connect to a 5ghz connection. I found this out the hard way after discovering the correct commands in the CLI.
  2. The string to run in the CLI goes as follows:

network update wlan0 --wifi-ssid YOURSSID --wifi-auth wpa-psk --wifi-psk YOURPASSWORD --ipv4-method auto --ipv6method auto

That’s it! You are done. You could replace the method auto with static info, but after 4 hours I just want it online. Cheers boys!

1 Like

I just want to say it is generally considered best practice to setup static IPs on the router and not the device itself. I know not all consumer grade routers will have this option, but if you do have a router that allows it I would recommend setting up the static IP via the router instead of your Home Assistant device.