首页 文章

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

提问于
浏览
12

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

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

  • 确保VMnet连接已连接(愚蠢,但必须检查......我也可以通过DHCP连接到Internet)

  • 确保Windows上的防火墙允许VMware连接到互联网

  • 我已经看到/读过Windows有时会阻止ping请求,所以我尝试在Firefox中访问www.google.com,这得到了"Server not found response" ...所以我必须为DNS做些不同的事情吗?

  • 我检查了我的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)

5 回答

  • 0

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

    dhclient -v
    

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

  • 48

    我刚刚解决了这个问题,不确定是否有人发现了这个问题 . 我如何为自己修复它是在VMware(我有第12个版本)我去了

    • 编辑

    • 虚拟网络编辑器

    • 恢复默认值

    • 然后点击OK

    • 我重新安装了Centos 7

    • 单击“网络和主机名”

    • 单击“以太网”

    • 等待填充详细信息,即ip地址,子网掩码,dns ......

    • 作品 .

    您可能不必卸载操作系统,只需先尝试编辑和虚拟网络编辑器,然后再恢复为默认值 . 这适用于您在VMware上安装的所有操作系统 .

  • 0

    从我所看到的,问题可能是您在设置IP地址时错过了在vm中设置dns条目 .

    请编辑

    nano /etc/resolv.conf
    nameserver 192.168.88.2
    

    名称服务器应该是您的网络的DNS服务器,如果它的家庭路由器应该与您的网关相同,或者只是检查您的电脑的网络并分配相同的DNS地址 .

    此外,如果您想使用静态IP地址,只需将模式更改为桥接网络并分配网络的IP地址和DNS .

    Nt适配器在不同子网中的IP地址与桥接网络不同,这与您的PC所在的网络相同 .

  • -2

    进一步的读者

    我遇到了同样的问题 . 有时问题可能在主机(Windows 10和VMware工作站12)中,例如在我的情况下 .

    检查VMnetDHCP服务是否正在运行 .

    right click on windows icon -> task manager -> service tab
    

    如果没有,则启动该服务并在VMware中重新启动来宾操作系统 .
    VMnetDHCP service

  • 1

    请确认 PREFIX= 不是 /32 并且是 24 或替换为 NETMASK=255.255.255.0

    简单的错误 .

    发现在你的

    /etc/sysconfig/network-scripts/eth****
    

相关问题