Network configuration under CentOS6.5 and CentOS7 (permanently effective)

Network configuration under CentOS6.5 and CentOS7 (permanently effective)

This article is a summary of the network configuration encountered in the work of the editor. If you have any questions or suggestions, you can contact the editor.

Tools/Materials

  • CentOS6.5 system

  • CentOS7 system

method/step

  • Configure the network under the pure version of CentOS6.5:

    1. After installing CentOS6.5, log in as root to enter the system

    2. Enter vi /etc/sysconfig/network-scripts/ifcfg-eth0 and press Enter

    3. Press the "i" key in the editing interface 

    Revise     

        ONBOOT=yes // Whether to activate the network card when the computer starts, the value here is yes     

        BOOTPROTO=static // The way to get IP, the value here is static 

    Add to     

        IPADDR=192.168.5.233 //IP address

        NETMASK=255.255.255.0 //Subnet mask

        GATEWAY=192.168.5.254 //Gateway address     

        DNS1=8.8.8.8     

        DNS2=114.114.114.114

    4. Press the Esc key and enter: wq! save and exit

    5. Enter service network restart to restart the network service

    6. Enter ifconfig and press Enter to check whether the configuration information takes effect

    7. Ping the local network, external network, and domain name to see if it can be pinged

  • Configure the network under the pure version of CentOS7:

    1. After installing CentOS7, log in as root to enter the system

    2. Enter ip a and press Enter to view the network card information, and record DEVICE and HWADDR for subsequent use

    3. Enter vi /etc/sysconfig/network-scripts/ifcfg-eno16777736 (DEVICE is used here)

    4. Press the "i" key in the editing interface 

    Revise     

        ONBOOT=yes     

        BOOTPROTO=static 

    Add to     

        HWADDR=Record made in step 2    

        IPADDR= set ip, such as: 192.168.5.233   

        PREFIX=24  

        GATEWAY=192.168.5.254  

        DNS1=8.8.8.8    

        DNS2=114.114.114.114

    5. Press the Esc key and enter: wq! save and exit

    6. Enter service network restart to restart the network

    7. Enter ip a and press Enter to see if the configuration information is written

    8. Ping the local network, external network, and domain name to see if it can be pinged

    9. After all can be pinged, enter yum install net-tools to retrieve the ifconfig command

    END

Precautions

  • It should be noted here that the above configuration methods are all static ip configuration methods.

  • The physical address IPADDR must be written correctly, otherwise the error "Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for deta" will appear when restarting the network service.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325824831&siteId=291194637