How Can I Test My sys-net Hostname?

I’m trying to spoof my hostname.

I have completed the steps described in this post of the Qubes Documentation:

However I don’t know how to verify it is working.

My NetVM does not visually change to a random number each time it starts up, it stays the same name I have it set as. When I run “hostname” in the NetVM terminal, it returns with “localhost”. Does anyone have experience/advice on spoofing my hostname? How can I test my hostname to see if its spoofing properly? Help me out if you can, thanks.

You can simply open a terminal in sys-net and see the randomized hostname in the prompt, e.g., [user@PC-1234 ~] instead of the default [user@sys-net ~].

You can also do:

[user@PC-1234 ~]$ echo $HOSTNAME
PC-1234

That’s weird.

The new hostname should be in your /etc/hostname and /etc/hosts files. If it’s not there, something went wrong. However it looks like something went wrong as hostname should also return the new one.

/rw/config/protected-files.d/protect_hostname.txt still exists after a reboot of sys-net?
(I guess you’re not using a disposable sys-net? Because if so, the instructions apply to the disposable template and the template’s template instead.)

Can you post the content of /etc/hosts and /etc/hostname?

Please also post the content of these files of the template VM of your sys-net for a comparison.

Hello! Not using a disposable sys-net. I just tried the instruction on the qubes documentation again, and am receiving the same result.

How can I check the state of /rw/config/protected-files.d/protect_hostname.txt ?

The Contents of template & sys-net:

[user@localhost] cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4.localdomain4 fedora-30
::1 localhost.localdomain localhost6 localhost6.localdomain6 fedora-30
[user@localhost] cat /etc/hostname
cat: /etc/hostname: No such file or directory

For step 1 of the instructions, I have been running the following command in a CLI Fedora Template VM

“sudo gedit /etc/NetworkManager/dispatcher.d/preup.d/00_hostname”

and then I have been adding the entire text in the command box included on the documentation, and saving. Is this correct? This seems like the only area where I could be messing up

Hello! Not using a disposable sys-net. I just tried the instruction
on the qubes documentation again, and am receiving the same result.

How can I check the state of
/rw/config/protected-files.d/protect_hostname.txt ?

ls -l /rw/config/protected-files.d/protect_hostname.txt in your sys-net.
(If it exists, it will be listed.)

The Contents of template & sys-net:

[user@localhost] cat /etc/hosts 127.0.0.1 localhost
localhost.localdomain localhost4.localdomain4 fedora-30 ::1
localhost.localdomain localhost6 localhost6.localdomain6 fedora-30
[user@localhost] cat /etc/hostname cat: /etc/hostname: No such file
or directory

Thanks. That looks like /etc/NetworkManager/dispatcher.d/preup.d/00_hostname doesn’t exist in your template or you forgot to make it executable.

Assuming it exists, as root (via sudo su) inside your sys-net template, run chown root:root /etc/NetworkManager/dispatcher.d/preup.d/00_hostname to make root the owner and chmod +x /etc/NetworkManager/dispatcher.d/preup.d/00_hostname to make it executable.

Also double check on step 2 via ls -l /etc/hosts.lock.

For step 1 of the instructions, I have been running the following
command in a CLI Fedora Template VM

“sudo gedit /etc/NetworkManager/dispatcher.d/preup.d/00_hostname”

and then I have been adding the entire text in the command box
included on the documentation, and saving. Is this correct? This
seems like the only area where I could be messing up

Yes, that was probably it (see above).

Enjoy!

1 Like

Thank you so much for the help, I really really appreciate it. However my hostname is still not being spoofed, and I am still dealing with the same issues. To be clear this is the process I just attempted.

Created sys-net VM based off of Fedora-30 Template.
In Fedora-30 Template CLI, I ran:

sudo gedit /etc/NetworkManager/dispatcher.d/pre-up.d/00_hostname

Then placed the entire code from the Qubes Documentation page, and saved.
Then in the Fedora-30 Template CLI, I ran:

  • sudo su
  • chown root:root /etc/NetworkManager/dispatcher.d/pre-up.d/00_hostname
  • chmod +x /etc/NetworkManager/dispatcher.d/pre-up.d/00_hostname
  • “touch /etc/hosts.lock”

Closed Fedora-30 Template VM.
Opened network VM CLI, I ran:

  • 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’

Restarted the network VM.
Hostname issue is still persisting.
Result is the same when running - cat /etc/hosts & cat /etc/hostname

For reference:
After step 2 of Qubes instructions, in the Template VM I ran -

  • ls -l /rw/config/protected-files.d/protect_hostname.txt

The result was -

-rw-r–r-- 1 root root 0 Nov 15 16:44 /etc/hosts.lock

In the network VM, I ran -

  • ls -l /rw/config/protected-files.d/protect_hostname.txt

The result was -

-rw-r–r-- 1 root root 25 Nov 15 16:54 /rw/config/protected-files.d/protect_hostname.txt

If you have any suggestion on what I can try next please let me know. Again thank you.

Sorry. I just did a fresh install of Qubes, and completed the steps I described above, and now the hostname is correctly randomizing. Thanks again for all the help man, I appreciate it.

Thank you

Hello everyone.
The same issue is happening in my system too. I have followed all the steps here. However it seems that the script itself is not executing. I have tried to manually create /etc/hostname file.
Could you please help?

Also I have modified the NetworkManager.conf file and added “hostname-mode=none” under main section to prevent network manager from interfering but to no avail.

Update : I tried to slightly modify the script to make it output text to a file in desktop after execution of particular lines in the script.
It is found out that the test file is not being created at all.

There can be one conclusion from this i.e. the script is not being executed at all when the NetVM is starting.

However if the script is not being executed then how come the hostname changes from “sys-net” to “local host” ?