Vagrant 桥接至 openvpn 接口?

Vagrant 桥接至 openvpn 接口?

设置:

运行 OpenVPN 服务器和一些 Vagrant 虚拟机的盒子

问题:

我希望像常规机器一样直接从 VPN 客户端访问 Vagrant 盒,而不是仅仅通过几个转发端口。

配置:

OpenVPN 有接口 tun0:

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.69.69.1  P-t-P:10.69.69.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:110348 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89923 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:18322866 (18.3 MB)  TX bytes:16651955 (16.6 MB)

Vagrant 配置了具有特定 ip 的 public_networks:

config.vm.network "public_network", :bridge => "tun0", ip:"10.69.69.101", :auto_config => "false", :netmask => "255.255.255.0"

但它不起作用,我猜是因为我无法将 Vagrant 桥接到 OpenVpn 接口?从日志中:

DEBUG network: Normalized configuration: {:auto_config=>"false", :bridge=>"tun0", :mac=>nil, :nic_type=>nil, :use_dhcp_assigned_default_route=>false, :ip=>"10.69.69.101", :netmask=>"255.255.255.0", :protocol=>"tcp", :id=>"9d8e9f11-8e10-442d-92a3-7c463e14cf24", :adapter=>2}
 INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "list", "bridgedifs"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: Name:            eth0
GUID:            30687465-0000-4000-8000-d43d7ee2ff6e
DHCP:            Disabled
IPAddress:       XXX.XXX.XXX.XXX
NetworkMask:     255.255.255.224
IPV6Address:     2a01:04f8:0200:6152:0000:0000:0000:0002
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: d4:3d:7e:e2:ff:6e
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-eth0

DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
DEBUG network: Bridge was directly specified in config, searching for: tun0
 INFO interface: info: Specific bridge 'tun0' not found. You may be asked to specify
which network to bridge to.
[default] Specific bridge 'tun0' not found. You may be asked to specify
which network to bridge to.
DEBUG network: Only one bridged interface available. Using it by default.
 INFO network: Bridging adapter 2 to eth0
DEBUG network: Adapter configuration: {:adapter=>2, :type=>:bridged, :bridge=>"eth0", :mac_address=>nil, :nic_type=>nil}

我是否应该通过 Virtualbox 桥接 tun0?或者这不可行?我尝试过这样做:

v.customize ["modifyvm", :id, "--nic1", "bridged", "--bridgeadapter1", "tun0"]

我是否应该创建一个虚拟接口 eth1(我不能使用 bridge0,因为它是一个公共 IP),并通过 Vagrant 桥接到它,然后为 OpenVPN 服务器创建路由规则?

相关内容