peter
peter

Reputation: 6137

Vagrant hostname that differs from machine name

It seems that no matter what I set as the vm.hostname value, running the command hostname yields the vagrant machine's name instead of the hostname I provided.

So, given this setup:

Vagrant.configure(2) do |config|
  config.vm.define "site1" do |s1_conf|
    s1_conf.vm.box = 'ubuntu/trusty64'
    s1_conf.vm.hostname = 'site1.dev'
  end
  config.vm.define "site2" do |s2_conf|
    s2_conf.vm.box = 'ubuntu/trusty64'
    s1_conf.vm.hostname = 'site2.dev'
  end
end

If I do vagrant ssh site2 and then hostname, I'll get "site2" not "site2.dev". Why?

Is my understanding of how this works wrong? Or is it supposed to work this way, and I have something else going on in my code?

Upvotes: 0

Views: 312

Answers (1)

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84343

Invalid Hostname Character

. is not a valid character for the hostname portion of a fully-qualified domain name (FQDN). Try site1-dev or site2-dev instead.

Upvotes: 2

Related Questions