Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Vagrant making up an incorrect subnet when it's just supposed to port-forward?

Host is Windows 8.1; provider is VirtualBox 4.3.4; Vagrant version is 1.3.5.

Host has just a single NIC, wired, with IP 192.168.1.100.

Vagrantfiles reads:

  config.vm.box = "precise64"
  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"

  config.vm.network :forwarded_port, guest: 80, host: 8080

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file  = "init.pp"
    puppet.options="--verbose --debug"

However, following vagrant up, the VM gets a completely wrong IP address. ifconfig for the guest reads:

vagrant@vagrant-ubuntu-precise-64:~$ ifconfig                   
eth0      Link encap:Ethernet  HWaddr 08:00:27:1a:b6:5e         
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.25
          inet6 addr: fe80::a00:27ff:fe1a:b65e/64 Scope:Link    
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1    
          RX packets:356 errors:0 dropped:0 overruns:0 frame:0  
          TX packets:239 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000                          
          RX bytes:38937 (38.9 KB)  TX bytes:33157 (33.1 KB)    

Why is Vagrant totally ignoring the port forwarding setting on the vagrantfile? IP address should be 192.168.1.xand instead I get this random 10.0.2.15. Any ideas?

Edit: Host can't even ping 10.0.2.15. No response, even when the VM is up. Something is very broken.

Edit 2: Now I'm getting /sbin/ip addr flush dev eth1 2> /dev/null on 2 different systems. Argh.

like image 802
ezuk Avatar asked Jan 10 '14 12:01

ezuk


1 Answers

Ssh into the machine

Delete the file /etc/udev/rules.d/70-persistent-net.rules

Exit the machine

Do a "vagrant reload"

I think that does the trick =]

like image 137
jonathanglima Avatar answered Nov 09 '22 01:11

jonathanglima