Unable to use static IPs in my VMs

Hi all, I have been searching for someone with this issue for a while and I have come up dry. The problem that I am having is that whenever I set any of my VMs to a static IP, the VM will lose all network connectivity. However when they use DHCP, they work just fine. I want my VMs to be assigned their own static IPs without having to rely on my router as a DHCP server because I dont currently have that on a battery backup but my network switches do, I have power outages pretty frequently.
I have tried with / without a network bridge but to no avail. Since neither of the options have netted success I have removed the network bridge and kept my system on just the Ethernet interface itself.
Whenever I set the VM on a static IP, I can ping it from my local machine SOMETIMES but it will still occasionally timeout. Whenever I try to ping my gateway, anything else on my network or even something on the internet like my DNS servers from the VM, it always drops the packets.

I have one VM running Ubuntu 24.04 LTS and another running Home Assistant OS. Both VMs experience this issue.

Bare with me, I’m not allowed to post images yet :sweat_smile:

SYSTEM INFORMATION
NAS information
Version 25.04.1 Baremetal

Network Configuration:
enp5s0: DHCP off,
aliases:
192.168.1.254/24

VM 1 Running Ubuntu
(NIC is using the enp5s0 interface)
NIC: eth0 (MACVLAN)

VM 2 Running HAOS
(NIC is using the enp5s0 interface)
NIC: eth0 (MACVLAN)

I have been using my Ubuntu box for testing, using netplan to change my configurations. Here are the two different configs I have been switching between

VM 1 DHCP Configuration:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      dhcp4: true

VM 1 Static IP Configuration:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      dhcp4: false
      addresses:
        - 192.168.1.253/24
     routes:
       - to: default
         via: 192.168.1.1
     nameservers:
       addresses: [1.1.1.1, 1.0.0.1]

I’m sure that this is a simple fix or something that I am just missing on my side, BUT, before anyone asks, yes, I checked to make sure that there were no devices on my network that were already configured with the IP that I chose in my static IP configuration.

Thanks in advance!

Where are you trying to set a static IP?

My HAOS uses a static IP without issue. I have a bridge configured on TrueNAS, which has it’s own static IP (my TrueNAS IP)

HAOS is connected to the bridge and I configured the static IP for HAOS from inside Home Assistant, not in TrueNAS.

Basically, I think you configure the static IP inside the guest OS running in your VM, not anywhere in the TrueNAS UI

1 Like

Hey Troy,
Thanks for your response, I am trying to set the static IP in the VM itself. The code block configurations are from my ubuntu VM where I am trying to set the IP to 192.168.1.253 with a subnet of 255.255.255.0. Do you mind going further in detail on how your setup is configured? I am interested to know if you did anything different to make it work.

Thanks

I have a really simple setup - My HAOS VM is connected to the same network as my TrueNAS. I created the bridge following Stux’s YouTube video.

Here’s a screenshot of my TrueNAS network settings.

My Instances Global Settings - Default Network are at the default values

When I created the VM, I unchecked Use default network settings and selected the bridge I created under Bridged Adaptors.

And finally, I set a static IP for HAOS in Home Assistant.

Hope that helps!

Another approach is to use a macvlan.
I run portainer as an App, which allows me to create the macvlan.
Then I statically allocate IPs from the macvlan.

For instance, my nas is on 192.168.3.10/24.
My DHCP server dynamically allocates from 64 thru 127.
I reserve the top 128 address for macvlan.

I created a macvlan with a /26, which gives me 129 thru 191 (something like that).

Plenty. I only need one or two.

My gitea statically allocates 192.168.3.131. Works a treat.

version: "3.4"

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - TZ=AEST
    restart: always
    networks:
      macvlan3:
         ipv4_address: 192.168.3.131
    volumes:
      - '/mnt/rpool/volume1/docker/gitea/data:/data'
      - '/etc/localtime:/etc/localtime:ro'
      - /mnt/rpool/volume1/docker/swag/config/etc/letsencrypt/live/example.com/fullchain.pem:/etc/ssl/certs/ssl-cert-snakeoil.pem:ro
      - /mnt/rpool/volume1/docker/swag/config/etc/letsencrypt/live/example.com/privkey.pem:/etc/ssl/private/ssl-cert-snakeoil.key:ro
    ports:
      - "3000:3000"
      - "22:22"
    cap_add:
      - NET_ADMIN
    extra_hosts:
      - "gitea.example.com:192.168.3.131"

networks:
  macvlan3:
    external:
      name: macvlan3

When using macvlan with TrueNAS, one needs to add similar to the following to system > advanced > init/shutdown

ip link add macvlan-lan link vlan03 type macvlan mode bridge
ip addr add 192.168.3.254/32 dev macvlan-lan
ip link set macvlan-lan up
ip route add 192.168.3.128/26 dev macvlan-lan

which enables the VMs on the macvlan to be able to access the truenas host.

1 Like

So I managed to follow the tutorial for the most part and then I branched it off on to my HAOS VM. I set a static IP but now the VM cant reach any DNS servers.

I tried using my gateway’s DNS and using Cloudflares IPs directly to no avail. Could there be more that I’m missing? I can post pictures now so if you need more information from me I can get it here much easier. Below is my new network configuration in TrueNAS as well. I don’t know where that interface in the middle is coming from but I can’t delete it… Could this be causing one of my issues?

HAOS VM configuration

TrueNAS network configuration

Thanks for the suggestion. I’m not too savy with networking or using apps like portainer. I’m sure that I would be able to figure it out with a little bit of documentation reading but for my own sake and sanity I would like to keep my setup as simple as possible to avoid future confusion. Thanks again!

Everything looks good, as far as I can see from your screenshots.

A couple of things I can suggest trying.

Open the VM shell and see if you can ping anything outside your network.

For example, ping google.com

I’m not sure why Static vs. DHCP would make a difference, but can you connect to NabuCasa if you set Home Assistant back to Automatic?

I’m sorry, I’m not a network person, so I’m unsure what else to try.

Static configuration:

After moving back to DHCP:

This has got to be one of the biggest head scratchers for me. This used to work fine when I was on release 22.xx(?) (forgot the other numbers :sweat_smile:) but then after I changed configurations both VMs would present this issue…
What is weird is that even though the HAOS VM would be on the static configuration and it couldn’t even ping my gateway, yet I can still access it from my desktop. I don’t know what kind of nonsense would even make this possible.

Bump!

Bumping again!
Any help would be greatly appreciated!

Sorry I can’t help.

I know its not the answer your looking for, but since things seem to work with DHCP, maybe you can mange the IP address on your router by setting a DHCP reservation to the desired IP.

Which is precisely what works for me.