"Linux" virtual machine after installing CentOS ping IP address error: Network is unreachable

Source: Internet
Author: User

Source: https://my.oschina.net/stonezing/blog/515480

Go to/etc/sysconfig/network-scripts/view the files below

Everyone has a different file, but the prefix is the same, VI Ifcfg-ens33

Change Onboot=no to onboot= Yes

Restart Services Service Network restart

The contents of the above file mean:

Open commands and information according to the file Ifcfg-eth0 as follows:

[Email protected] ~]# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0#网卡设备名称

Onboot=yes#启动时是否激活 yes | no

Bootproto=static#协议类型 DHCP BOOTP none

ipaddr=192.168.1.90#网络IP地址

netmask=255.255.255.0#网络子网地址

gateway=192.168.1.1#网关地址

broadcast=192.168.1.255#广播地址

hwaddr=00:0c:29:fe:1a:09#网卡MAC地址

Type=ethernet#网卡类型为以太网

Source: http://blog.csdn.net/julius819/article/details/7652463

Brother Bird will speak more clearly: http://cn.linux.vbird.org/linux_server/0130internet_connect_1.php

4.1.3 Linux Network Related configuration file case

We know that the important parameters of TCP/IP are: IP, Netmask, Gateway, DNS IP, and do not forget that you should also have a host name (hostname)! In addition, we also know that the acquisition of IP has manual settings, DHCP processing and so on. So what are these parameters mainly written in which configuration files? How does it correspond? Let's take care of it at the bottom!

required network parameters main profile file name important parameter
IP
Netmask
DHCP or not
gateway
/etc/sysconfig/network-scripts/ifcfg-eth0 device= Nic's code name
bootproto= whether to use DHCP
hwaddr= to add a network card number (MAC)
Ipaddr= is the IP address
netmask= only network shield
onboot= do not start this interface by default
gateway= It's the communication gate.
nm_controlled= Additional network management software
Bird Brother suggested to cancel the project!
host name /etc/sysconfig/network networking= want to have network
Networ king_ipv6= Support IPv6 no?
Hostname= Your host name
DNS IP /etc/resolv.conf nameserver DNS IP
Private IP corresponds to
host name
/etc/hosts Private IP hostname alias

You have not read wrong, the main need to change is the four files only! So it's not very difficult! We all think too much! Detailed setting of the next section, the first concept here. In addition, there are some files that you should also know about better yo!

    • /etc/services
      This file is the total protocol that records the schema on TCP/IP, including HTTP, ftp, SSH, Telnet, and so on, as defined by the port number, which is planned by this file. If you want to customize a new protocol corresponding to the port, you have to change the file;

    • /etc/protocols
      This file defines the relevant data for the IP packet protocol, including the definition of the packet protocol for the ICMP/TCP/UDP.

Probably know the above several files, the future to modify the network parameters, it is too simple! As for the network start-up instructions, you can remember a few simple instructions to do Oh!

    • /etc/init.d/network restart
      This script is the most important! Because the parameters of the entire network can be restarted in a breath! He will take the initiative to read all the network configuration files, so you can quickly restore the system default parameter values.

    • Ifup eth0 (Ifdown eth0)
      Start or close a network interface. Can be handled through this simple script! These two script will take the initiative to the/etc/sysconfig/network-scripts/directory, read the appropriate configuration file to deal with Ah! (e.g. Ifcfg-eth0).

Maybe you just have to go to these basic instructions and files, haha! The setting of network parameters is too simple! However, it is better for you to understand shell script. Because you can track the set conditions of the entire network. Why? This is because each distributions setting data may not be the same, but all use/etc/init.d/network as the startup script, so you can easily trace the contents of your profile as soon as you know the contents of the file. Right!

"Linux" virtual machine after installing CentOS ping IP address error: Network is unreachable

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.