Hello everyone
im creating this school project: i have 4 Vagrantmachines joined by a private network with Static IPs.
I also overrode the route so they cannot access internet with the default network created by Vagrant:
route '0.0.0.0/0' do
gateway 192.168.33.13
device eth0
end
My goal is to reroute the internet access by giving them the gateway of 1 machine that will have a 2nd network adapter public network (using ip tables and all the other stuffs). I also want to give my public network the ip address of my host.
This is the Vagrantfile of my gateway machine:
system('
ip="$(ifconfig | grep -A 1 "en0" | tail -1 | cut -d ":" -f 2 | cut -d " " -f 2)"
echo $ip
')
Vagrant.configure("2") do |config|
# https://docs.vagrantup.com.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.13"
config.vm.network "public_network" ip: "IP OF MY HOST MACHINE HERE"
config.vm.synced_folder ".", "/vagrant"
config.vm.define "gateway" do |web|
web.vm.box = "debian/jessie64"
end
config.vm.provision "chef_solo" do |chef|
# chef.add_recipe "default-route"
chef.add_recipe "router"
chef.cookbooks_path = "../chef-repo/cookbooks"
end
end
The system part at the beginning is a shell command to recover the ip address of my host machine, and now i would like to recover that value and insert it on the ip address of my public network but i cannot manage to do it.
Any advices??
Thank you!!