vagrant-landrush / landrush

A Vagrant plugin that provides a simple DNS server for Vagrant guests
MIT License
666 stars 78 forks source link

Windows: hostname vs FQDN #276

Closed proteansec closed 5 years ago

proteansec commented 7 years ago

The relevant part of the Vagrantfile is shown below, where the problematic option is highlighted.

config.vm.define "vagrant-win8x86-enterprise" config.vm.box = "win8x86-enterprise" config.vm.hostname = "win8x86-enterprise"

create a private network

config.vm.network :private_network, ip: "172.28.128.5" config.vm.communicator = "winrm" config.winrm.username = 'vagrant' config.winrm.password = 'vagrant' config.vm.guest = :windows

enable landrush DNS

if Vagrant.has_plugin?("landrush") config.landrush_ip.auto_install = true config.landrush.enabled = true config.landrush.guest_redirect_dns = false config.landrush.host_redirect_dns= false config.landrush.host 'win8x86-enterprise.vagrant.test', '172.28.128.5' end

Then running vagrant up, there's an error when setting the hostname of the guest Windows machine, because I've specified the FQDN name.

==> vagrant-win8x86-enterprise: Machine booted and ready! Sorry, don't know how to check guest version of Virtualbox Guest Additions on this platform. Stopping installation. ==> vagrant-win8x86-enterprise: Checking for guest additions in VM... Stopping daemon... Sending KILL to process 27161... ==> vagrant-win8x86-enterprise: Setting hostname... Renaming the Windows guest failed. Most often this is because you've specified a FQDN instead of just a host name.

Ensure the new guest name is properly formatted. Standard names may contain letters (a-z, A-Z), numbers (0-9), and hypens (-), but no spaces or periods (.). The name may not consist entirely of digits.

Ok, I get the point, let's modify the config.landrush.host option to only include the hostname without the domain part. The relevant part of the Vagrantfile is again shown below.

config.vm.define "vagrant-win8x86-enterprise" config.vm.box = "win8x86-enterprise" config.vm.hostname = "win8x86-enterprise"

create a private network

config.vm.network :private_network, ip: "172.28.128.5" config.vm.communicator = "winrm" config.winrm.username = 'vagrant' config.winrm.password = 'vagrant' config.vm.guest = :windows

enable landrush DNS

if Vagrant.has_plugin?("landrush") config.landrush_ip.auto_install = true config.landrush.enabled = true config.landrush.guest_redirect_dns = false config.landrush.host_redirect_dns= false config.landrush.host 'win8x86-enterprise', '172.28.128.5' end

After doing vagrant up I again receive an error, this time about the hostname not matching the configured TLD vagrant.test.

==> vagrant-win8x86-enterprise: Machine booted and ready! Sorry, don't know how to check guest version of Virtualbox Guest Additions on this platform. Stopping installation. ==> vagrant-win8x86-enterprise: Checking for guest additions in VM... ==> vagrant-win8x86-enterprise: [landrush] removing machine entry: win8x86-enterprise Stopping daemon... Sending KILL to process 2001... ==> vagrant-win8x86-enterprise: Setting hostname... ==> vagrant-win8x86-enterprise: Configuring and enabling network interfaces... ==> vagrant-win8x86-enterprise: Landrush IP not installed in guest yet (or it's an outdated version). Installing now. ==> vagrant-win8x86-enterprise: [landrush] hostname win8x86-enterprise does not match the configured TLD: vagrant.test ==> vagrant-win8x86-enterprise: [landrush] You will not be able to access win8x86-enterprise from the host ==> vagrant-win8x86-enterprise: [landrush] adding machine entry: win8x86-enterprise => 172.28.128.5

Therefore, the error says I have to configure the hostname back as it was before, but that also produced an error.

hferentschik commented 7 years ago

I am a bit confused. Are you sure that in particular the first error is attributable to Landrush. config.landrush.host does not try to set the hostname of the guest. It just adds a static DNS entry for the specified hostname to its configuration.

TBH, I am not sure exactly what's going on. What is the Windows guest you are using? Are there any readily available for testing?

proteansec commented 7 years ago

I'm using the following iso image: http://data.alsyundawy.com/Windows%208/en_windows_8_enterprise_x86_dvd_917587.iso . Basically you can just install the windows normally, create a vagrant box and then issue the relevant vagrant commands.

This is a landrush error, because of the following line - I thought the vagrant.test is the default, which is why I'm not sure why landrush is checking and failing upon that.

==> vagrant-win8x86-enterprise: [landrush] hostname win8x86-enterprise does not match the configured TLD: vagrant.test

hferentschik commented 7 years ago

A FQDN is expected in this case, since the domain part is also used to re-configure your DNS on the host. Only request to the VM domain will be directed to the Landrush DNS server.

So your first attempt is the correct one, however, it seems that for Windows guests the hostname cannot contain a fully qualified name. This is actually from the Vagrant codebase and I assume that Windows just does not allow setting a fully qualified name. See also:

In the case where you only specify the hostname, you get an error message from Landrush. It assumes the default domain 'vagrant.test', but this does not match what's specified in the hostname config option. This is mainly an issue for configuring DNS on the host. I guess we could use a warning message in this case.

This alone won't help much though, since we generally have no support for Windows guests - see issue #278.

mklemm2 commented 7 years ago

I stumbled upon this problem some time ago. I solved it by writing a small plugin that provides a "windowsplus" guest and overrides the ChangeHostName capability.

The new capability allows specifying FQDNs. It then sets the hostname part as hostname and the domain part as primary dns suffix.

I don't know much ruby and therefore have no idea how stable the code is, but it works for me. If you want, I can put it on github.

boonen commented 7 years ago

@mklemm2 can you share the fix/plugin already?

mklemm2 commented 7 years ago

@boonen Here it is: https://github.com/mklemm2/vagrant-GuestWindowsPlus

hferentschik commented 5 years ago

Closing this issue, since it is really a Vagrant core thing.