Recover Host IP and use it for public network

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 '' do
  device eth0

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:

        ip="$(ifconfig | grep -A 1 "en0" | tail -1 | cut -d ":" -f 2 | cut -d " " -f 2)"
        echo $ip

Vagrant.configure("2") do |config|

  # "forwarded_port", guest: 80, host: 8080

  # "forwarded_port", guest: 80, host: 8080, host_ip: "" "private_network", ip: "" "public_network" ip: "IP OF MY HOST MACHINE HERE"
  config.vm.synced_folder ".", "/vagrant"

  config.vm.define "gateway" do |web| = "debian/jessie64"

  config.vm.provision "chef_solo" do |chef|
    # chef.add_recipe "default-route"
    chef.add_recipe "router"
    chef.cookbooks_path = "../chef-repo/cookbooks"


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!!