DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Change IP Address of NAT NIC in Vagrant VM


The default IP address of Vagrant VM is 10.0.2.15. So you can't connect to a host with IP in range "10.0.2.*". If you do want, you must change the IP address of NAT NIC (network interface card) via the modifyvm command of VBoxManage:

VBoxManage modifyvm <vm-name> --natnet1 "10.3/16"

The here can be listed by command "VBoxManage list vms".

In vagrant we can achieve this by adding "config.customize ["modifyvm", :id, "--natnet1", ]" into your vm config of Vagrantfile, for example, the following config will change the IP address of NAT NIC to "10.3.0.15":

config.vm.define "bs" do |bvtserver|
  bvtserver.vm.hostname = "bvt-server"
  bvtserver.vm.network "private_network", ip: "192.168.50.3",
      virtualbox__intnet: "gcptest-network"
  bvtserver.vm.provider :virtualbox do |vbox|
    vbox.customize ["modifyvm", :id, "--natnet1", "10.3/16"]
  end
end


Published

Feb 27, 2014

Last Updated

Feb 27, 2014

Category

Tech

Tags

  • IP 3
  • NAT 1
  • Vagrant 12

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor