Setting a static IP for Truenas Virtual Machines?

Problem:

I have an ASUS router, you can set a static IP address, but that setting is based on the MAC Address of the “device” to which the IP is attached.

I run a few applications on a couple of virtual machines - and every time I reboot the Truenas Box - they receive different IP addresses because their MAC address changes.

Is there anyway to set the MAC address so that it does not change in Truenas?
Anyway to set the Router so that it doesn’t care what the MAC address is and assigns the IP to the “name” of the device (which doesn’t change).
Or any other work around?

It is becoming irritating updating all of my bookmarks every time I have to restart Truenas…

what hypervisor we are talking about?

no, but it is not normal that the MAC is changing every reboot, but a workaround would be a static IP.
Just go to the networking settings of truenas and set it to static, use a address outside of your DHCP range.

Truenas is where the virtual machine is location.

Truenas is already set to static and receives the same IP address, but the virtual machines in it do not get the same MAC address so cannot be set outside of Truenas.

I am not sure how you go about setting a static IP address for the VM in Truenas.

this is also not normal, which version of TrueNas?
This is the current Version of Scale
TrueNAS-SCALE-22.12.3.2
If you have an older Version consider an update.

This from the Truenas forums:

“What’s happening here is you have not specified the MAC address on the NIC in your VM devices, so every reboot, it will invent a new one and your router sees it as a new device because it has a new MAC address (as expected).”

I don’t think this is “broken” or that Truenas needs updating.

I believe there is a method for setting either a static IP or a persistent MAC address. Unfortunately the thread from which that message originates does not provide the route by which to complete this task.

interesting, I didn’t notice, I’ve been using TrueNas Core and Scale for years, but not really for virtualization and when, I give the VM a static IP. Strange default setting

I would look in the NIC configuration in the VM setup on TN. A good VM setup would allow you to enter the mac, TN VM setup is mediocre at best.

If that doesn’t work then MAC address can be set inside the VM when you are configuring the virtual NIC. You probably should check if the mac you see indie the VM is the mac that the router sees. If they are the same, then hopefully you can change the mac inside the VM, and it will propogate outside to the router, then you can assign a static lease to the VM.

If that doesn’t work, then maybe you can setup a bridge inside TN and attach the VM nic to the bridge, and see if then you can configure a mac address at the TN level, or if the previous setup mac inside the VM works.

In short - no, you cannot assign a dhcp static lease based on “hostname” usually.

However, I believe that the MAC addresses of the virtual boxes does not change upon reboot - if you have not done anything special with the assigned NICs on said VMs.

So, verify your nic’s on the virtual machines - if you feel it’s needed -assign static MAC-addresses on them, use those to assign static dhcp leases.

Or, simply don’t run DHCP on the full subnet - and assign manual static IP addresses on said VMs.

I asked Chat GPT - and it told me to go put a static IP address in a 00-config file in /etc/netplan and then do a sudo netplan apply.

Seems to have worked.

1 Like