CentOS 6.X NIC (eth0) automatic activation method
1. automatically activate the NIC
After CENTOS 6.x is installed, You need to manually activate the NIC every time you start the system. The following methods can be used to automatically activate the NIC after the system starts.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"HWADDR="00:0C:29:FC:1C:72"NM_CONTROLLED="yes"ONBOOT="no"
Change ONBOOT to yes
Vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = "eth0"
HWADDR = "00: 0C: 29: FC: 1C: 72"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
Save and exit (I prefer to use ZZ of vi to save and Exit)
# Service network restart
Then let's talk about the network configuration of centos 6.
1. Network Configuration
(1) command configuration
# Ifconfig eth0 192.168.0.2 netmask 255.255.255.0 // ip address, subnet mask
# Route add default gw 192.168.0.1 dev eth0 // Gateway
# Hostname centos // computer name
(2) file configuration
Modify IP Address
Modify the configuration file of the corresponding Nic IP Address
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 (describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file)
BOOTPROTO = static, IP addresses obtained through the bootp protocol)
BROADCAST = 192.168.0.255 (corresponding subnet BROADCAST address)
HWADDR = 00: 07: E9: 05: E8: B4 (corresponding Nic physical address)
IPADDR = 12.168.1.2 (if the IP address obtained by the NIC is set to static, the IP address corresponding to the NIC is specified in this field)
IPV6INIT = no (enable or disable IPv6; Disable no, enable yes)
IPV6_AUTOCONF = no (enable or disable automatic IPv6 Configuration; Disable no, enable yes)
NETMASK = 255.255.255.0 (network mask corresponding to the NIC)
NETWORK = 192.168.1.0 (NETWORK address corresponding to the NIC)
ONBOOT = yes (whether to set this network interface when the system starts. If it is set to yes, the device is activated when the system starts)
Modify Gateway
Modify the gateway configuration file of the corresponding Nic
# Vi/etc/sysconfig/network
NETWORKING = yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
HOSTNAME = centos (set the Host Name of the local machine. The host name set here must correspond to the host name set in/etc/hosts)
GATEWAY = 192.168.1.1 (set the IP address of the GATEWAY connected to the local machine. For example, the gateway is 10.0.0.2)
Modify DNS
Modify the DNS configuration file of the corresponding Nic
# Vi/etc/resolv. conf
Nameserver 202.101.224.68 (Domain Name Server)
Nameserver 202.101.224.69 (Domain Name Server)
Restart Network Configuration
# Service network restart
Or
#/Etc/init. d/network restart