From 577a5222d92673725bbfbcfa36a4fd59a7c2e82f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 24 Feb 2015 09:30:58 -0800 Subject: [PATCH] website/docs: wording of default router docs --- .../v2/networking/public_network.html.md | 99 +++++++++++-------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/website/docs/source/v2/networking/public_network.html.md b/website/docs/source/v2/networking/public_network.html.md index e79021cbe..a0a29371d 100644 --- a/website/docs/source/v2/networking/public_network.html.md +++ b/website/docs/source/v2/networking/public_network.html.md @@ -25,8 +25,8 @@ general public access to your machine, public networks can.

- Warning! Vagrant boxes are insecure by default - and by design, featuring public passwords, insecure keypairs + Warning! Vagrant boxes are insecure by default + and by design, featuring public passwords, insecure keypairs for SSH access, and potentially allow root access over SSH. With these known credentials, your box is easily accessible by anyone on your network. Before configuring Vagrant to use a public network, @@ -60,43 +60,6 @@ bridged interface. To do so, add a `:ip` clause to the network definition. config.vm.network "public_network", ip: "192.168.0.17" ``` -## Disable Auto-Configuration - -If you want to manually configure the network interface yourself, you -can disable Vagrant's auto-configure feature by specifying `auto_config`: - -```ruby -Vagrant.configure("2") do |config| - config.vm.network "public_network", auto_config: false -end -``` - -Then shell provisioner can be used to configure the ip of the interface: - -```ruby -Vagrant.configure("2") do |config| - config.vm.network "public_network", auto_config: false - #manual ip - config.vm.provision :shell, run: "always", inline: "ifconfig eth1 192.168.0.17 netmask 255.255.255.0 up" - #manual ipv6 - config.vm.provision :shell, run: "always", inline: "ifconfig eth1 inet6 add fc00::17/7" -end -``` - -## Default Router - -Depending on your setup, you may wish to manually override the default router configuration. This is required if you need access from other networks to the Vagrant box over the public network. To do so, you can use a shell provisioner script. - -```ruby - config.vm.network "public_network", ip: "192.168.0.17" - #default router - config.vm.provision :shell, run: "always", inline: "route add default gw 192.168.0.1" - #default router ipv6 - config.vm.provision :shell, run: "always", inline: "route -A inet6 add default gw fc00::1 eth1" - #delete default gw on eth0 - config.vm.provision :shell, run: "always", inline: "eval `route -n | awk '{ if ($8 ==\"eth0\" && $2 != \"0.0.0.0\") print \"route del default gw \" $2; }'`" -``` - ## Default Network Interface If more than one network interface is available on the host machine, Vagrant will @@ -110,3 +73,61 @@ config.vm.network "public_network", bridge: 'en1: Wi-Fi (AirPort)' The string identifying the desired interface must exactly match the name of an available interface. If it can't be found, Vagrant will ask you to pick from a list of available network interfaces. + +## Disable Auto-Configuration + +If you want to manually configure the network interface yourself, you +can disable auto-configuration by specifying `auto_config`: + +```ruby +Vagrant.configure("2") do |config| + config.vm.network "public_network", auto_config: false +end +``` + +Then the shell provisioner can be used to configure the ip of the interface: + +```ruby +Vagrant.configure("2") do |config| + config.vm.network "public_network", auto_config: false + + # manual ip + config.vm.provision "shell", + run: "always", + inline: "ifconfig eth1 192.168.0.17 netmask 255.255.255.0 up" + + # manual ipv6 + config.vm.provision "shell", + run: "always", + inline: "ifconfig eth1 inet6 add fc00::17/7" +end +``` + +## Default Router + +Depending on your setup, you may wish to manually override the default +router configuration. This is required if you need access the Vagrant box from +other networks over the public network. To do so, you can use a shell +provisioner script: + +```ruby + config.vm.network "public_network", ip: "192.168.0.17" + + # default router + config.vm.provision "shell", + run: "always", + inline: "route add default gw 192.168.0.1" + + # default router ipv6 + config.vm.provision "shell", + run: "always", + inline: "route -A inet6 add default gw fc00::1 eth1" + + # delete default gw on eth0 + config.vm.provision "shell", + run: "always", + inline: "eval `route -n | awk '{ if ($8 ==\"eth0\" && $2 != \"0.0.0.0\") print \"route del default gw \" $2; }'`" +``` + +Note the above is fairly complex and may be guest OS specific, but we +document the rough idea of how to do it because it is a common question.