CentOS 6.5 Sets the static IP tutorial and can ping through

Source: Internet
Author: User

CentOS6.5 power down or reboot, its IP will be reassigned by DHCP, if you want to remotely control the computer, you have to open the monitor to see its new IP, it is too troublesome. So the IP of this computer needs to be set to static.

After setting up the static IP on the Internet, it can't ping, such as ping www.baidu.com display ping:unknown host www.baidu.com

After repeated experiments and online access to information, finally solved the problem. The following is the Setup method and description.

I use VMware to install the Centos6.5, and the following will say the VMware settings.

Do some preparatory work:

Prepare one. Confirm that the VMware Network Adapter VMnet8 is turned on to view the IP address. For example mine is: 192.168.182.1

Preparation two. Review the virtual machine settings to ensure that the network configuration of the virtual machine CentOS is NAT, as


(important)In the virtual machine menu, edit-Virtual network Editor-in the dialog box, select VMware network Adapter VMnet8 NIC and select the NAT mode for the following vmnet information. ( Note the IP address segment does not show 182 because the article is not written at the same time. IP address according to the actual situation, do not be disturbed by the picture

To set a static IP step:

(1) Find/etc/sysconfig/network-scripts/ifcfg-eth0 This file, if not create one, the content is as follows

[Plain]View Plaincopy
  1. Device= "Eth0"
  2. bootproto= "Static"
  3. Hwaddr= "00:0C:29:6D:72:5A"
  4. Type= "Ethernet"
  5. onboot= "Yes"
  6. Broadcast= "192.168.182.255"
  7. Ipaddr= "192.168.182.100"
  8. netmask= "255.255.255.0"
  9. Gateway= "192.168.182.2"
  10. dns1= "192.168.182.2"
  11. #DNS2 = "8.8.8.8"
  12. #IPV6INIT = "Yes"
  13. #NM_CONTROLLED = "Yes"
  14. #UUID = "4973dfb0-ad81-4846-bc64-1009221f51c0"

Device=eth0 #描述网卡对应的设备别名

Bootproto=static #设置网卡获得ip地址的方式, the possible options are static,dhcp or BOOTP, corresponding to statically specified IP addresses, IP addresses obtained through the DHCP protocol, IP addresses obtained through the BOOTP protocol

broadcast=192.168.182.255 #对应的子网广播地址, stay on the same network segment, end is 255

Onboot=yes

Ipaddr=192.168.182.100 #设置自己喜欢的ip地址, stay on the same network segment

netmask=255.255.255.0 #网卡对应的网络掩码

gateway=192.168.182.2 #保持在同一网段, set to 2 at the end

dns1=192.168.182.2 #DNS1服务器的地址, stay on the same network segment, and at the end set to 2. you can use Nslookup in cmd to find

For these two GATEWAY,DNS must be set according to the rules above, otherwise it cannot be ping.

(2) Locate the/etc/sysconfig/network file with the following contents. This can be used without setting

[Plain]View Plaincopy
  1. Networking=yes
  2. Hostname=localhost.localdomain
  3. #NETWORKING_IPV6 =no
  4. #GATEWAY =192.168.182.2

Networking=yes #表示系统是否使用网络, generally set to Yes. If set to no, the network cannot be used, and many system services programs will fail to start

Hostname=localhost.localdomain #设置本机的主机名, the host name set here corresponds to the hostname set in/etc/hosts

(3) View/etc/resolv.conf file

[Plain]View Plaincopy
    1. # generated by networkmanager  
    2. nameserver 192.168.182.2 

This file does not need to be modified, it is automatically generated according to the network card configuration file/etc/sysconfig/network-scripts/ifcfg-eth0. Even if modified, the content will be flushed out after restarting the network service.

(4) Restart Network Service

[Plain]View Plaincopy
    1. Service Network restart

OK, now that the static IP is set, and can ping the network

Reference Address: http://blog.csdn.net/daydreamingboy/article/details/8199069

Reference Address: http://blog.csdn.net/simpleiseasy/article/details/8711492

CentOS 6.5 Sets the static IP tutorial and can ping through

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.