我有以下问题:
我有一台安装了 CentOS 的虚拟机。我无法从这台机器连接到互联网,因此无法升级其上安装的任何内容。
VM 配置为:
在设置 -> 网络下
- 适配器 1
- NAT
- 适配器 2
- 主机专用适配器
- 名称:vboxnet0
- 混杂模式:拒绝
- Calbe Connected:是的
在“文件”->“首选项”->“网络”下的“仅主机网络”中,vbonenet0:
- IPv4 地址:192.168.101.1
- Ipv4 网络掩码:255.255.255.0
- IPv6 地址:fe80:0000:0000:0000:0800:27ff:fe00:0000
- IPv6 前缀长度:64
当我在机器上时:
ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:55:45:B3
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe55:45b3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1699 (1.6 KiB) TX bytes:1414 (1.3 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:D7:3D:E9
inet addr:192.168.101.129 Bcast:192.168.101.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fed7:3de9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:477 errors:0 dropped:0 overruns:0 frame:0
TX packets:452 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:89736 (87.6 KiB) TX bytes:183141 (178.8 KiB)
ping 192.168.101.129
PING 192.168.101.129 (192.168.101.129) 56(84) bytes of data.
64 bytes from 192.168.101.129: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.101.129: icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from 192.168.101.129: icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from 192.168.101.129: icmp_seq=4 ttl=64 time=0.048 ms
64 bytes from 192.168.101.129: icmp_seq=5 ttl=64 time=0.062 ms
ping www.google.com
PING www.google.com (216.58.205.164) 56(84) bytes of data.
From 192.168.101.129 icmp_seq=2 Destination Host Unreachable
From 192.168.101.129 icmp_seq=3 Destination Host Unreachable
From 192.168.101.129 icmp_seq=4 Destination Host Unreachable
在下面/etc/sysconfig/网络脚本/, 这ifcfg-eh0文件:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=DHCP
DNS1=8.8.8.8
DNS2=8.8.4.4
这ifcfg-eh1文件:
DEVICE=eth1
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.101.129
NETMASK=255.255.255.0
NETWORK=192.168.101.0
BROADCAST=192.168.101.255
NM_CONTROLLED=no
DNS1=8.8.8.8
DNS2=8.8.4.4
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.101.0 * 255.255.255.0 U 0 0 0 eth0
10.0.3.0 * 255.255.255.0 U 0 0 0 eth1
192.168.56.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
link-local * 255.255.0.0 U 1003 0 0 eth1
default 192.168.101.2 0.0.0.0 UG 0 0 0 eth0
有人能帮助我吗?谢谢你的支持。
更新
默认网关是:
ip r | grep default
default via 192.168.101.2 dev eth1
答案1
确保 VirtualBox 网络适配器的 MAC 地址等于文件 ifcfg-eh0 和 ifcfg-eh1 中声明的硬件地址 (HWADDR)。直到我修复了这个问题,我的网络才能够正常工作。