How to set up gateway of public network in vagrant

deDishari picture deDishari · Feb 10, 2014 · Viewed 9.7k times · Source

I am setting up my Virtualbox Centos VM with vagrant. I am setting up with a public network.

config.vm.network :public_network, ip: "10.135.15.137"

How do I setup the GATEWAY along with this?

Answer

Nikos Alexandris picture Nikos Alexandris · Dec 13, 2015

According to the (new) documentation, setting up a gateway, can be done by instructing the following, inside the Vagrantfile:

# default router
config.vm.provision "shell",
  run: "always",
  inline: "route add default gw 192.168.0.1"

Read the complete example titled Default Router at http://docs.vagrantup.com/v2/networking/public_network.html.