CentOS Virtual Machine ping www.baidu.com prompt to find unknown host, a check is not set IP on the virtual machine next to my DNS is not.
The command settings are as follows:
1. Enter Ifconfig to see if there is any information for lo and eth0,
One: If you only have lo, you need to manually create the eth0.
Second: If you have eth0, manually modify his parameters.
2. First, create the parameters we need by naming them.
Vi/etc/sysconfig/network-scripts/ifcfg-eth0,
I, enter the Insert edit mode, the specific parameters are set as follows:
Device=eth0
Bootproto=none (can also be set to static IP address)
Onboot=yes
Type=ethernet
netmask= Subnet Mask
Ipaddr=ip No.
Userctl=no
Ipv6init=no
Peerdns=yes
gateway= Gateway (consistent with the gateway on your machine)
ESC, exiting edit mode
shift+:wq! Save and Exit commands
3.ifconfig-a to see if it takes effect.
4.service network restart, Web server restart
5.ping +ip (IP set by virtual machine), prompt success
6.ping + Gateway, prompted as follows, on behalf of our set or there is a problem
7. Manually set up DNS with the following command
vi/etc/resolv.conf;
I, enter insert mode, set as follows:
nameserver=8.8.8.8 (This is the Google default setting, of course you can set the same as the DNS on your machine)
ESC, exit edit mode;
shift+:wq! Save and Exit commands
8.service network restart, Web server restart
9.ping + Gateway, if not, you need to detect your virtual machine network settings. If NAT is selected by default, the bridge mode is changed.
10. After Setup, reboot your virtual machine, ping+ Gateway, PING+IP should be successful
11.ping+www.baidu.com appears as follows, which means the setup was successful ~
Ifconfig only lo and no eth0 solution