Centos network configuration (terminal environment)

Source: Internet
Author: User
Tags nameserver

The server version of centos is installed in the Virtual Machine for hadoop-related experiments. Centos for server does not have a desktop environment by default, and eth0 is not enabled by default. We need to manually start the network.

Key configurations

Network and host name configuration: Vim/etc/sysconfig/network.

The configuration file is as follows:

Networking = yes # Use Network hostname = centos # Set Host Name

 

Nic configuration: Vim/etc/sysconfig/network-scripts/ifcfg-eth0

Eth0 indicates the first Nic. The configuration is described as follows:

Device = eth0 # corresponding to the first Nic type = ethernetonboot = yes # whether to run nm_controlled = yesbootproto = static # use a static IP address instead of an IP address allocated by DHCP. The static IP address is configured here, if it is DHCP, simply change the configuration below DHCP to ignore it. Defroute = yesipv4_failure_fatal = yesipv6init = noname = "system eth0" # Name: hwaddr = 00: 50: 56: 94: 04: 3C # It must correspond to the MAC address (/etc/udev/Rules) of etho. d/70-persistent-net.rules) peerdns = yespeerroutes = yesipaddr = 192.168.1.40 # specify the local IP address netmask = 255.255.255.0 # specify the subnet mask gateway = 192.168.1.1 # specify the Gateway

 

DNS-related configuration (you can select the row configuration. Generally, the network environment is OK and does not need to be configured separately): Vim/etc/resolv. conf

Nameserver 8.8.8.8 # Google's DNS server nameserver xx. xx # backup DNS server nameserver 192.168.1.1 # specify the DNS server specified on the router
Test

Restart the network service through service network restart and use ifconfig to check whether IP Address Allocation is normal.

Centos network configuration (terminal environment)

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.