在 Windows 上使用 vagrant 时,vm 实例未将默认设置为桥接模式
vm instance not setting up default to Bridged mode when using vagrant on Windows
我尝试关注此线程:Vagrant how to set network type so that its attached to bridge adapter on Virtual Box 遇到类似问题但没有成功。
也试过这个:
和 Vagrant 文档 https://www.vagrantup.com/docs/providers/virtualbox/configuration 是 Linux 具体的。
这是我的 vagrant 文件。
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "xoan/proxmox-ve_6.4"
config.vm.box_version = "1.0.0"
config.vm.network "forwarded_port", guest: 8006, host: 8006
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network", auto_config: false, Bridged: 'Realtek PCIe GbE Family Controller #5', ip: "192.168.56.2",
nic_type: "virtio"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = 2048
vb.cpus = "2"
vb.name = "proxmox1"
end
end
我将 NAT 指定为桥接模式,并为其指定 VirtualBox 所见的以太网卡名称。 (指定名称,因为我有多个网卡接口)
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'xoan/proxmox-ve_6.4'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'xoan/proxmox-ve_6.4' version '1.0' is up to date...
==> default: Setting the name of the VM: proxmox1
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 8006 (guest) => 8006 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
但每次我运行 vagrant up 我都会默认使用 NAT 1
转发到 127.0.0.1 的端口是正确的 NAT,您应该尝试从您的主机 ping ip 192.168.56.2
。你应该能够使用私钥ssh这个ip,即
ssh -i private_key 192.168.56.2
我尝试关注此线程:Vagrant how to set network type so that its attached to bridge adapter on Virtual Box 遇到类似问题但没有成功。
也试过这个:
和 Vagrant 文档 https://www.vagrantup.com/docs/providers/virtualbox/configuration 是 Linux 具体的。
这是我的 vagrant 文件。
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "xoan/proxmox-ve_6.4"
config.vm.box_version = "1.0.0"
config.vm.network "forwarded_port", guest: 8006, host: 8006
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network", auto_config: false, Bridged: 'Realtek PCIe GbE Family Controller #5', ip: "192.168.56.2",
nic_type: "virtio"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = 2048
vb.cpus = "2"
vb.name = "proxmox1"
end
end
我将 NAT 指定为桥接模式,并为其指定 VirtualBox 所见的以太网卡名称。 (指定名称,因为我有多个网卡接口)
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'xoan/proxmox-ve_6.4'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'xoan/proxmox-ve_6.4' version '1.0' is up to date...
==> default: Setting the name of the VM: proxmox1
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 8006 (guest) => 8006 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
但每次我运行 vagrant up 我都会默认使用 NAT 1
转发到 127.0.0.1 的端口是正确的 NAT,您应该尝试从您的主机 ping ip 192.168.56.2
。你应该能够使用私钥ssh这个ip,即
ssh -i private_key 192.168.56.2