vagrant Multipe networking - networking

I have installed magento 2 in vagrant with in docker machine, this docker machine have port forwarding concepts, I set private network, with nat and host-only, Now only access magento 2 in hostmachine.
I need to access locally connected remote machine also so, i try to change private network to public network with bridge.
Vagrant File:
Vagrant.configure("2") do |config|
config.vm.box = "machine"
config.ssh.username = "vagrant"
config.vm.hostname = "www.myhost.net"
config.ssh.forward_agent = "true"
config.vm.network "public_network", ip: "192.168.56.40"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
if Vagrant::Util::Platform.windows?
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777", "fmode=777"]
else
config.vm.synced_folder ".", "/vagrant", :nfs => { :mount_options => ["dmode=777", "fmode=777"] }
end
end
But, throw
NFS requires a host-only network to be created.
Please add a host-only network to the machine (with either DHCP or a
static IP) for NFS to work.
I need to add Multiple Network to vagrant
nat
host-onloy(for nfs)
bridge (for access remote machine)
Suggest me How to resolve this.

You need to change your public_network to private_network for nfs to work
If you are using the VirtualBox provider, you will also need to make sure you have a private network set up. This is due to a limitation of VirtualBox's built-in networking. With VMware, you do not need this.
so :
you can change to VMWare (but you have some additional fees)
you do not use nfs
you can setup another network interface for bridge and use this network interface if you need to connect to the remote machine, you should be able to ping (ping -I ethX mylocalmachine) but I am not sure how to work to get connection in

Related

Kubernetes networking issue bridged adapter

I am working on setting up a multi-node, multi hardware server Kubernetes Cluster.
I am using Calico and Kubeadm.
So I am trying to use a bridge adapter within VMS to allow visibility over the network to a remote server using promiscuous mode and a static IP address.
The issue is when the VM is created, I cannot ping into it.
I have used to initialize kubeadm:
kubeadm init --apiserver-advertise-address="192.168.2.50" --apiserver-cert-extra-sans="192.168.2.50" --node-name master --pod-network-cidr=192.168.0.0/16
I am asking if there's an additional networking config to enable ping the Vms successfully.
This is the code I've used into the vagrantfile:
s.vm.provider "virtualbox" do |v|
v.name = vM_NAME
v.customize ['modifyvm', :id, '--nictype3', 'Am79C973']
v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
v.memory = 2048
v.gui = false
end
s.vm.network "private_network", ip: "192.168.2.#{i + m - 1}",# netmask: "255.255.255.0",
auto_config: true,
virtualbox__intnet: "k8s-net"
s.vm.network "public_network", bridge: "Intel(R) Ethernet Connection I217-LM", ip: "192.168.2.#{i + m -1}",# netmask: "255.255.255.0",
auto_config: true
Thank you.
While doing kubeadm init add the PUBLIC IP and PORT as part of --control-plane-endpoint parameter.
sudo kubeadm init --apiserver-advertise-address=x.x.x.x --apiserver-cert-extra-sans=x.x.x.x **--control-plane-endpoint=y.y.y.y** --node-name master --pod-network-cidr=z.z.z.z/16
Worker nodes over the network can join the master node using the new generated join-command.

connection refused from host machine

I am using vagrant with virtualbox as provider. Within my guest system I have nginx installed and configured.
nginx is serving some static files from a folder and exposing them on port 80. That works fine. If I call curl localhost within the guest machine I get the answer I was supposed to receive.
I have a very simple vagrantfile, which you can see below. I forward port 80 to port 8080, but from the host machine I cant access that page via localhost:8080.
I already disabled the firewall in the guest machine without any success.
Vagrant.configure("2") do |config|
# VirtualBox Settings: Give it a little bit more memory
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "768"]
end
# Base Image: CentOS 7.0 x86_64
config.vm.box = "jayunit100/centos7"
# Use Vagrant's default insecure key (~/.vagrant.d/insecure_private_key)
config.ssh.insert_key = false
# Add port forwarding for node-inspector
config.vm.network :forwarded_port, guest: 80, host: 8080 # node-inspector
# Map project directory
config.vm.synced_folder ".", "/server/"
# Provisioning Shell Script
config.vm.provision :shell, :path => "vagrant-setup/base.sh"
end
If I call curl -v 'http://localhost:8080' from the host system I get told that the connection got refused. Any idea what I could do?
I had to disable my firewall on the host machine with iptables -F

Guest ip is unreachable under Vagrant using private network

I have next vagrant file on my windows host
Vagrant.configure(2) do |config|
config.vm.provider :virtualbox do |v|
v.customize [
"modifyvm", :id,
"--memory", 1024,
"--cpus", 1,
]
end
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.0.101"
end
Virtual machine starts normally but is unreachable from host by "192.168.0.101" ip. /etc/network/interface on guest is
auto lo
iface lo inet loopback
source /etc/network/interfaces.d/*.cfg
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet static
address 192.168.0.101
netmask 255.255.255.0
#VAGRANT-END
and /etc/network/interfaces.d/eth0.cfg is
auto eth0
iface eth0 inet dhcp
Additionally after each run that vagrant, the new virtual network adapter is created and inside Virtualbox UI tool I see info about that new network - real IP is diffrent and random i.e. 169.254.173.8. I had >20 virtual networks :) By that IP guest machine is pinged and from itself also. But after restart vagrant the new network will be created with new IP
How to run vagrant machine with static unchangable IP? I need to build cluster with several nodes and each node must know about IP of each one
Update:
On Linux host machine all it's OK. I can ping all guests from my host and guets see each other
On Windows guests can't ping other guests i.e. 192.168.0.101 can't see 192.168.0.102
The private network is just that, private to the guest(s), and it's created in addition to the default NAT-ed adapter. If you have several guests, they can interact with each other on the private network.
Regarding the nodes interacting, there are a number of plugins that can help you manage that, both with actual DNS as well as more simply using /etc/hosts. I tried a few and settled on vagrant-hosts.

Vagrant with VPN connection over host computer

I'm trying to get my Vagrant CentOS box connected to VPN thru my host computer. I followed this: https://gist.github.com/mitchellh/1277049
but I still can't connect to the VPN only hosts.
I'm on Vagrant version 1.3.5 and CentOS release 6.4.
Vagrant configs: config.vm.network :public_network and, as noted by the link above, I have
vb.cusotomize["modifyvm", :id, "--natdnshostresolver1", "on"]
With this setup I don't get any errors, it just doesn't seem to be working. I can reach hosts on my host machine but not thru my VM. When the VM is booting I choose my 2) en0: Ethernet 1 connection.
As Terry Wang answered, remove public_network and as then follow this answer https://superuser.com/questions/542709/vagrant-share-host-vpn-with-guest
The newer versions of Vagrant will only use host as dns with this:
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
The Gist 1277049 is using default NAT networking for the Vagrant box.
However, you are using Public Network (Bridged) with your en0. That's why it is NOT working.
NOTE: I don't think you can bridge to a VPN connection (virtual adaptors, no driver). By using NAT, you are able to access the systems on the other side of the VPN connection.
To fix, just comment out the config.vm.network :public_network line. By default it'll use NAT and the box should be able to access whatever the host is capable of.

Setting subnet mask In vagrant for public network

I need to run some services in vagrant, so that its accessible in browser. By giving network type as public_network in Vagrantfile, I am getting a vagrant Ip (10.251.70.201).
Now, using this vagrant Ip am able to get these service in other device's browser (which are in the same network: 10.251.70.*). Now I need to expand the visibility of the vagrant Ip in other networks (like 10.251.*.*). How can I achieve this?
I assume you are using Virtualbox provider. As an example:
config.vm.network "public_network", :netmask => "255.255.0.0"
This is example of using Virtualbox provider for Vagrant version 2 config file:
config.vm.network "public_network", bridge: "eth0", ip:"192.168.1.20", netmask:"255.255.0.0"

Resources