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?
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?
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.
Vagrant 2.0.1 has a configuration option for this which is explained in the documentation:
Vagrant → Networking → Public Networks → Using the DHCP Assigned Default Route
For your convenience, here is the relevant section (retrieved 2018-05-15):
Using the DHCP Assigned Default Route
Some cases require the DHCP assigned default route to be untouched. In these cases one may specify the use_dhcp_assigned_default_route option. As an example:
Vagrant.configure("2") do |config| config.vm.network "public_network", use_dhcp_assigned_default_route: true end
Adding a solution for ubuntu with netplan to set the default gateway to the public network. persistent across reboots.
config.vm.provision "shell", inline: <<-SHELL
cat <<EOF >> /etc/netplan/60-override.yaml
---
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp4-overrides:
use-routes: false
eth1:
dhcp4: true
EOF
netplan apply
sleep 5
SHELL
© 2022 - 2024 — McMap. All rights reserved.
sudo route add default gw 10.0.0.1 eth1
– Radiogram