我有一个托管在 ubuntu 上的 centos 虚拟机,在 ubuntu 上我连接到 open-connect VPN,我想通过 centos 6.7 虚拟机使用这个 VPN。
我已经像这样设置了 Virtual Box 仅主机网络:
vboxnet0
adapter:
ipv4 address: 192.168.56.1
ipv4 network mask: 255.255.255.0
DHCP server :
enable server
server address: 192.168.56.100
server mask: 255.255.255.0
lower address bound: 192.168.56.101
upper address bound: 192.168.56.254
然后我配置了 centos Vbox 网络如下:
适配器1:
attached to : Host-only adapter
name : vboxnet0
适配器 2:
attached to : NAT
然后我配置了 centos 网络设置如下:
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=ff99b59d-162f-4838-baa7-c73384ab23f2
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:1D:BD:69
DEFROUTE=yes
NAME="System eth0"
并且:
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=ff99b59d-162f-4838-baa7-c73384ab23f2
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
NAMEE="System eth1"
然后我重新启动 Vbox,当重新加载 Vbox 并输入 ifconfig 时,我得到:
eth0 Link encap:Ethernet HWaddr 08:00:27:1D:BD:69
inet addr:192.168.56.102 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe1d:bd69/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:192 errors:0 dropped:0 overruns:0 frame:0
TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26123 (25.5 KiB) TX bytes:19725 (19.2 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:ED:C4:BD
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:feed:c4bd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:735 (735.0 b) TX bytes:1075 (1.0 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:315 errors:0 dropped:0 overruns:0 frame:0
当我 ping4.2.2.4
或8.8.8.8
收到以下信息时:
connect: Network is unreachable
任何帮助都感激不尽!
谢谢!
答案1
我已设法通过将虚拟机(centos)适配器1设置为来解决此问题NAT并将适配器 2 连接至仅主机网络
然后我将虚拟盒网络(仅主机网络选项卡)配置为:
vboxnet0
ipv4 address : 192.168.56.1
ipv4 network mask : 255.255.255.0
并启用DHCP
服务器并进行如下配置:
server address : 192.168.56.100
server mask : 255.255.255.0
lower address bound : 192.168.56.101
upper address bound : 192.168.56.254
然后我启动了我的虚拟机并对其进行了如下配置:
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:1D:BD:69
DEFROUTE=yes
NAME="System eth0"
DNS1=8.8.8.8
DNS2=4.2.2.4
并且 :
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
NAMEE="System eth1"
重新启动机器后它就正常工作了。它可以使用我的主机网络