Can't enable port forwarding due to No base MAC address error - vagrant

I am trying to enable port-forwarding so i can access my vagrant box from my local machine, but whenever i run my vagrant box i get this error,
No base MAC address was specified. This is required for the NAT networking
to work properly (and hence port forwarding, SSH, etc.). Specifying this
MAC address is typically up to the box and box maintainer. Please contact
the relevant person to solve this issue.
But when I re-run vagrant up command, it works just fine except that I can't ping it from my host machine.
I am using the following line in my Vagrantfile to enable port forwarding,
config.vm.network :forwarded_port, guest: 80, host: 4567
and I am trying to ping it in my host machine as follows,
ping 127.0.0.1:4567
Can someone please tell me how can I fix this mac error issue so that I can ping and access my box from my local machine ?
EDIT:
I have tried this code to set the MAC address but its not doing anything either.
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--macaddress1", "auto"]
end

Related

How can I configure private network in vagrant box

Setup:
On my laptop, I have windows 10 pro install. On that, I have installed latest virtualbox 5.1.2, latest vagrant 1.9.1 and latest packer 0.12.1. My laptop is highend and with strong configuration. I am on wifi.
Purpose:
I want to have three vagrant boxes running Windows 2012 r2 so that I can install SQL server on one, and two different web applications on others.
Success:
Till now I have managed to create vagrant boxes without any hassles. If I use forwarded port method, I am even able to rdp into those machines.
Failure:
My plan is to configure private network for these machines so that they can have their own ip addresses and can communicate with each other. But so far I am unable to achieve so. The private network settings as recommeded on vagrantup.com and other websites do not seem to work for me somehow, as I am sure I am doing some mistake somewhere.
can somebody please help me on how to go about this? I have searched a lot on this site also and gone through many suggestions but none seem to help.
Below is my vagrant file that I am using.
Vagrant.configure(2) do |config|
config.vm.box = "xxxx.box"
config.vm.communicator = "winrm"
config.vm.hostname = "xxxserver"
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
config.windows.halt_timeout = 600
config.vm.network "private_network", ip: "192.168.50.4"
end
And below is the error message that I get when I run vagrant rdp
*
==> default: Detecting RDP info... RDP connection information for this machine could not be detected. This is typically caused when we can't
find the IP or port to connect to for RDP. Please verify you're
forwarding an RDP port and that your machine is accessible.
*
But if I replace
config.vm.network "private_network", ip: "192.168.50.4"
with
config.vm.network "forwarded_port" , host: 33390 , guest: 3389
and then reload the box then vagrant rdp works fine and I am able to loginto it. I want to use static ips for my vms.
Kindly guide..
thanks.
I also use a private_network with a static ip. Only adding (not replacing) the line config.vm.network "forwarded_port" , host: 33390 , guest: 3389 works.
$ vagrant rdp
==> fe: Detecting RDP info...
fe: Address: 127.0.0.1:33389`enter code here`
fe: Username: vagrant
==> fe: Vagrant will now launch your RDP client with the connection parameters
==> fe: above. If the connection fails, verify that the information above is
==> fe: correct. Additionally, make sure the RDP server is configured and
==> fe: running in the guest machine (it is disabled by default on Windows).
==> fe: Also, verify that the firewall is open to allow RDP connections.

Networking errors causing vagrant machine not to start up

I ran into the following error when I execute "vagrant up" command.
The specified host network collides with a non-hostonly network!
This will cause your specified IP to be inaccessible. Please change
the IP or name of your host only network so that it no longer matches that of
a bridged or non-hostonly network.
Vagrant file:
Vagrant.configure("2") do |o|
o.vm.box="centos/7"
o.vm.network "private_network", ip: "192.168.1.13"
o.vm.provision "shell", :path=>"setup.sh"
end
setup.sh:
sudo yum -y update
sudo yum -y install vim,git,gedit,nmap
sudo systemctl restart httpd
Nothing is started but I see a machine in Virtual box and I double click and I start as usual. Could assign static IP but no network to outside world. Not sure where the things are going wrong.
Any help would be very much appreciated.
Thanks
Jim
I'm not sure I've seen that particular error before. However I do have some Vagrant (VirtualBox) VMs that use both a private network to talk to each other, and NAT to talk to the wider world.
I make sure these don't conflict by specifying different private IPv4 network ranges for each. For example:
Vagrant.configure(2) do |config|
# host-only interface address
config.vm.network "private_network", ip: "192.168.0.2"
# NAT interface address range
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--natnet1", "172.16.0.0/12"]
end
end

How can I access a vagrant guest from another virtualbox guest?

The scenario is that my dev environment is on a Vagrant box on my laptop (host) and I would like to do browser testing in a vitualbox vm, so I need to see one vm from another.
The vagrant box's port is :8080 which is forwarded to the host on the same port :8080. So I can see the server from the host at localhost:8080
Which address should I be using for the browser testing vm?
The testing vm's default gateway?
The vagrant vm's ip?
The host's virtual network ip?
And should I be using a NAT or host only adapter on the browser testing vm?
That makes for a lot of combinations, all of which I believe I have tried. What else do I need to understand here?
In your use case, you should be using Bridged networking (Public Network in Vagrant). If the VMs reside on the same host, you can even use internal (Private Network in Vagrant).
If using Public Network, the VM's 2nd NIC will be able to obtain an IP address from the DHCP server in your network (e.g. your home router).
Simply add the following code block in your Vagrantfile and do a vagrant reload
Vagrant.configure("2") do |config|
config.vm.network "public_network"
end
You should be able to get the IP address by using vagrant ssh and ifconfig / ip addr show.
In case you don't want to go with public_network just like me then you should do the steps below using private_network:
Open Vagrantfile from your project root
Search for config.vm.network
Add this line config.vm.network "private_network", ip: "192.168.33.10". Remember this is not the IP of your base machine it's a virtual-box IP address and your machine IP should be different. You can say it's a fake IP address so change it to anything else like 192.168.30.20.
Reload your vagrant using vagrant reload.
Now go to your other virtual guest in my case it's the Windows Guest 2. My base is Linux Mint Vagrant box is on Ubuntu Guest 1. Open C:\Windows\System32\drivers\etc\hosts file as admin and do the above IP's entry in there like 192.168.33.10 local.youralias.com. And save the file, after that you can now browse the site now at http://local.youralias.com/.
In case your guest 2 is also Linux just edit this file sudo vi /etc/hosts, and add this line at top of it 192.168.33.10 local.youralias.com. Now save and exit and browse the URL :)
Enjoy! Happy coding.
Adding to accepted answer, you can actually set IP and specify which network interface to use.
My setup on linux box via wifi and static IP:
You can find your wifi interface name by running ifconfig command.
Vagrant.configure("2") do |config|
config.vm.network "public_network", :bridge => 'wlp8s0', ip: "192.168.1.199"
end
This may have many source cause. In my case, I use vagrant fedora boxe.
I tried:
First using the private_network that I attached to a host only adapter and launched httpd service to test the connection between guest and host
config.vm.network "private_network", type: "dhcp", name: "vboxnet2"
config.vm.network "forwarded_port", guest:80, host:7070
but I was not able to ping my guest machine from the host and could no telnet the httpd service opened
Second using public_network and launched httpd service to test connectivity
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", use_dhcp_assigned_default_route: true
I could ping my guest from my host but I could not telnet the httpd service.
For this two use case, the issue was that the port 80 on the fedora guest host was blocked by the firewall. Here is what fixed the issue and get all working for both privat_network and public_ntwork:
firewall-cmd --permanent --add-port 80/tcp #open the port permanently
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --list-port # list to check if the port was opened
systemctl stop firewalld # stop and open the firewall service
systemctl start firewalld
Old question, new answer: [disclaimer: i am not a vagrant expert]
both solutions might work but the solution in the "vagrant way of thinking" is that some component in your guest (rinetd?) should forward any requests to unknown ports to the host. From the host the request could then be mapped (via vagrant port forwarding) to a services that is running in the other guest.
So, to resume:
1.in guest-1 we do localhost:1234. Guest-1 will detect that this port is not available and forward to host
2. the host will check the vagrant port forwarding and forward to guest-2
3. in guest-2 we have some nice service listening to post 1234
4. done.

vagrant provisioned virtualbox cannot access the internet when booted up with an active VPN connection on the windows 7 host

I have a problem with networking while setting up a development virtual machine
The host environment is:
Windows 7x64
Vagrant 1.7.2
Virtualbox 4.3.20 r96997
has an active WLAN internet connections
can connect to a VPN
The relevant sections from the Vagrantfile are:
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.define 'crm' do |node|
node.vm.network :private_network, ip: '192.168.56.2'
end
end
With this, the guest machine has two network interfaces:
eth0: NAT
eth1: the private network
After a vagrant up the machine is always accessible through the private IP.
However, if at boot time the VPN connection
is active, then the guest machine cannot access the internet
is not active, then the guest machine can access the internet
On the host machine, with an active VPN connection, both public and VPN-restricted hosts are accessible.
Question: how should I modify the Vagrantfile to ensure that the guest machine always has internet access, regardless whether it was booted with an active VPN connection on the host machine or not?
Update:
adding
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
solves the internet connectivity issue, however, it brings the boot time of the guest machine to barely tolerable (many minutes)
ok. i had the same problem but i am using windows. i did fix it. what i did is that opened virtualbox.
go to settings
select network
change second adapter
select under " attached to: " ' Host-only Adapter'
under name. i selected " virtualbox host-only ethernet apdapter " do not select the name that have numbers at the end of the name example : #1, #2 and so on.
i went to my device manager and delete all the virtual network drivers "not your physical network drivers". again this was in windows 8.
i restart my pc
confirm my chance have applied
i vagrant up on my project directory and it was working

vagrant add an interface without setting an IP address

I'm working through the puppet openstack instructions, and one of the requirements is as follows:
Each of the machines running the Openstack services should have a minimum of 2 NICS.
One for the public/internal network. This nic should be assigned an IP address
One of the virtual machine network. This nic should not have an ipaddress assigned
I've tried to specify a private network in Vagrant without an address, but hit the following error when calling vagrant up:
* An IP is required for a private network.
My first thought is to run a provision script to set the network, but there are warnings not to modify the network configuration files (the box is CentOS):
[vagrant#localhost ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth2
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.55.5
NETMASK=255.255.255.0
DEVICE=eth2
PEERDNS=no
#VAGRANT-END
Any ideas will be appreciated!
In the end, I created an 'unmanaged' network card by adding a virtualbox internal network:
vb.customize ["modifyvm", :id, "--nic2", "intnet"]
This works:
config.vm.network :private_network, ip: ""
You can try this:
node.vm.network :private_network, "ip": '0.0.0.0', auto_network: true

Resources