0

I have written a multi-vm vagrant file, first I am not able to ssh using vagrant ssh dnsmasq to the first vm and for second vm the public network is not getting created i.e. after I ssh to pihole vm, it only had private network.

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
PUBLIC_NET_BRIDGE = 'Realtek PCIe GbE Family Controller #5'
PIHOLE_PUBLIC_IP =  "192.168.0.111"
DNSMASQ_PUBLIC_IP = "192.168.0.121"


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.synced_folder ".", "/vagrant", mount_options: ["dmode=700,fmode=600"]
  config.vm.box = "ubuntu/xenial64"
  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
    v.cpus = 1
    v.customize ["modifyvm", :id, "--usb", "off"]
    v.customize ["modifyvm", :id, "--usbehci", "off"]
  end

  config.vm.define "dnsmasq" do |d|
    # d.provider.name = ""
    d.vm.provider :virtualbox do |dvb|
      dvb.customize ["modifyvm", :id, "--name", "dnsmasq"]
    end
    d.vm.hostname = "dnsmasq"
    d.vm.network "public_network", ip: DNSMASQ_PUBLIC_IP, bridge: PUBLIC_NET_BRIDGE

    d.vm.provision "shell", inline: <<-SHELL
      apt-mark hold ubuntu-advantage-tools
      apt-get update
      apt-get upgrade -y
      apt-get install dnsmasq -y
    SHELL

    d.vm.provision "shell", path: "provision.sh"

    d.vm.provision "shell", inline: <<-SHELL
      systemctl enable consul
      systemctl restart dnsmasq
      systemctl start consul
    SHELL
  end

  config.vm.define "pihole" do |p|
    # p.provider.name = "pihole"
    # p.vm.hostname = "pihole"
    p.vm.provider :pihole do |pvb|
      pvb.customize ["modifyvm", :id, "--name", "pihole"]
    end
    p.vm.network "public_network", ip: PIHOLE_PUBLIC_IP, auto_config: false, bridge: PUBLIC_NET_BRIDGE
    
    p.vm.provision "shell", inline: <<-SHELL
      apt-mark hold ubuntu-advantage-tools
      apt-get update
      apt-get upgrade -y
      apt-get install net-tools dnsutils -y
    SHELL
    end
end

enter image description here

1 Answer 1

0

auto_config: false, this is the difference between two vm public network configuration Public Networks you can configure static IP on public network with two methods; auto_config needs inline provisioning, easy way to do this is just define static IP along with public network

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.