无法将CentOS VM连接到Internet(NAT连接)

gor*_*ysc 12 centos vmware-workstation centos6

因此,在过去一天与VMWare网络巨头作战之后,我决定让步并寻求帮助.我在Windows 7上运行的CentOS 6映像使用VMWare Workstation 8.0.2 build-591240上的NAT,由于某种原因,我无法再使用静态IP地址连接到Internet.这似乎只适用于静态,而不是DHCP,它告诉我它是:我的Windows 7操作系统上的某个程序阻止了该IP地址的连接,或者我的配置在CentOS映像上发生了一些奇怪的事情.

我不知道这是否是由于yum更新,所以我尝试重新安装VMWare工具.这似乎没有解决问题.我也尝试过以下方法:

  1. 确保VMnet连接已连接(愚蠢,但必须检查...我也可以使用DHCP连接到Internet)
  2. 确保Windows上的防火墙允许VMware连接到Internet
  3. 我已经看到/读过Windows有时会阻止ping请求,所以我尝试在Firefox中访问www.google.com,这得到了"服务器未找到响应"...所以我必须为DNS做些不同的事情吗?
  4. 我检查了我的Windows机器的注册表,我只有一个默认网关的条目

就像我说的那样,这似乎突然发生了.图像可以连接到互联网之前没有问题.是否有人知道可能导致此问题的CentOS更新?我在下面添加了我的配置以节省一些调试周期:

[root@MyCentOS ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:A0:51:BD
          inet addr:192.168.88.128  Bcast:192.168.88.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:683 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:64242 (62.7 KiB)  TX bytes:8055 (7.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1049 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1049 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:68417 (66.8 KiB)  TX bytes:68417 (66.8 KiB)


[root@MyCentOS ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
IPV6INIT="no"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR=192.168.88.128
NETMASK=255.255.255.0
GATEWAY=192.168.88.2
TYPE="Ethernet"

[root@MyCentOS ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=MyCentOS
GATEWAY=192.168.88.2

[root@MyCentOS ~]# service iptables status
iptables: Firewall is not running.
[root@MyCentOS ~]# service ip6tables status
ip6tables: Firewall is not running.
[root@MyCentOS ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@MyCentOS ~]# ping 192.168.88.2
PING 192.168.88.2 (192.168.88.2) 56(84) bytes of data.
64 bytes from 192.168.88.2: icmp_seq=1 ttl=128 time=0.391 ms
64 bytes from 192.168.88.2: icmp_seq=2 ttl=128 time=0.271 ms
^C
--- 192.168.88.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1349ms
rtt min/avg/max/mdev = 0.271/0.331/0.391/0.060 ms

[root@MyCentOS ~]# ping www.google.com
ping: unknown host www.google.com

[root@MyCentOS ~]# uname -a
Linux MyCentOS 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@MyCentOS ~]# vmware-toolbox-cmd -v
8.8.2.10499 (build-590212)
Run Code Online (Sandbox Code Playgroud)

小智 50

最好的选择是让它从DHCP自动获取IP:

dhclient -v
Run Code Online (Sandbox Code Playgroud)

这将让centos自动获得一个ip.

  • 我会接受这一点,因为没有其他人在这个帖子中添加任何东西,希望它能让一些人受益.但是,这背后的主要驱动因素是我想要一个静态IP地址,而接受的答案是非静态地址.在进一步研究之后,我发现另一个可行的解决方案是简单地将静态IP地址更改为另一个地址.我猜测VMware改变了我下面的MAC地址,并保持IP地址绑定到旧的MAC.简而言之,如果您遇到此问题,请尝试分配不同的静态IP地址. (2认同)