Disposable netvm: spoofing hostname

I followed this guide to randomizing mac address successfully. But when look up to randomizing hostname, it have to run this command in netvm:

# 3. Execute inside your network VM:
#  `sudo bash -c 'mkdir -p /rw/config/protected-files.d/ && echo -e "/etc/hosts\n/etc/hostname" > /rw/config/protected-files.d/protect_hostname.txt'`

Base on my knowledge, anything you do on a disposable vm, will be vanished when shutdown, therefore I think it is not work on the disposable netvm.

Any of you can successfully randomize your hostname on the disposable netvm? What is your work to achieve that goal?

Did you try bind dirs?

My suggestion would be to make a netvm template that you can launch disposable VMs from. On that template you could store / set-up whatever scripts you need ran at boot. (How exactly varies based on base distro. Debian 11 you would probably use systemd and tons of google articles show you how.) Then you could technically spin up multiple templates

Thanks for suggestions, however these idea seems too “technical” for me, I need some solutions that simpler. Or maybe just do step3 on disposable-template(app-vm that the disp-netvm relays on)? But it seems won’t work too…(haven’t test though)

Add step 3 command (without sudo ) to /rw/config/rc.local in your disposable-template.

Thanks for help again!