How to change hostname using CLI

Started by scoobey, March 20, 2024, 06:05:51 AM

Previous topic - Next topic
So I did this thing and now my system hangs at getting an IP on the WAN interface. I can interrupt the boot process and get to a CLI and hopefully I can recover it.

What did I do? I changed the host name to "66STST" it really does not like the host name starting with a number and gave no warning.

I am very confident this is what happened as I tried it two more ti.es on new VMs that all resulted in the same result

Is there a way to edit the configuration to fix the hostname?

there is a config.xml file where you can change

<hostname>OPNsense</hostname

but did you keep a backup xml??  you could modify the backup and load it back in.

Cant imagine that only this hostname is the reason for it. How did things go?

March 20, 2024, 06:56:47 PM #3 Last Edit: March 20, 2024, 07:15:16 PM by scoobey
Quote from: hansen97124 on March 20, 2024, 06:32:10 AM
there is a config.xml file where you can change

<hostname>OPNsense</hostname

but did you keep a backup xml??  you could modify the backup and load it back in.


I found the config.xml file in the /config folder.

I changed the host name so it starts with an "alpha" character and now the system boots.

Maybe this calls for a little Input Validation to ensure that you cannot change the hostname of OPNsense from the webgui.

Similar issues may arrise if you attempt to create a static DHCP/Firewall Rule etc if you start a hostname with a number. Depending on what Hostname RFC the systems in question are using. It might be safer to ensure that the original RFC that stated hostnames had to start with an Alpha character {a-z}. While I thought this might be related to the DHCP server (Arris DSL Modem) even with the Network Cable to OPNsense disconnected it would not boot when the hostname started with a number. OPNsense is virtualized in Proxmox 8 latest version and connected via a Linux Virtual Bridge to the physical adapter. It could be Proxmox or OPNsense that is using an outdated RFC in regards the structure of the Hostname.