Avoid:
Back up the original file before any operation. We agree that the name of the backup file is: source file name + Bak. For example, the original file name is centos.txt.
The backup file name is centos.txt Bak.
Introduction:The IP address of the Linux Nic is stored in the file. The configuration file is stored in/etc/sysconfig/network-scripts,
The names are ifcfg-eth0, ifcfg-eth1, etc.
If you only have one Nic, there is only one ifcfg-eth0 file,
If you have two or more NICs, there will be ifcfg-eth1, ifcfg-eth2, and other files.
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
========================================================== ========================================================== ====
Check that the computer has several NICs:
Enter the following terminal commands:
CD/etc/sysconfig/network-scripts # enter the/etc/sysconfig/network-scripts folder
Ls-1 # view all the files in the/etc/sysconfig/network-scripts folder and find that there is only one ifcfg-eth0, indicating that the computer has only one Nic
CD # Return
CP/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0bak110816 # backup file
VI/etc/sysconfig/network-scripts/ifcfg-eth0 # enter the NIC ifcfg-eth0 Profile
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
Device = eth0 # specify the device name nm_controlled = yes # The Network mamager parameter takes effect in real time. You do not need to restart onboot = yes # Set it to yes, automatically enable the network connection at startup ipaddr = 192.168.21.129 # IP address bootproto = none # Set to none to disable DHCP, set to static to enable static IP address, set to DHCP to enable DHCP service netmask = 255.255.255.0 # subnet mask dns1 = 8.8.8.8 # first DNS server type = Ethernet # network type: ethernetgateway = 192.168.21.2 # Set gateway dns2 = 8.8.4.4 # Second DNS server ipv6init = No # disable ipv6userctl = No # allow non-root users to control the device and set it to No, only root users can change hwaddr = 00: 0C: 29: 2C: E1: 0f # Nic MAC address prefix = 24 defroute = yesipv4_failure_fatal = yesname = "system eth0" # define the device name WQ! # Save and exit
CP/etc/resolv. CONF/etc/resolv. confbak110816 # backup file
VI/etc/resolv. conf # Set the DNS server
# Generated by NetworkManager nameserver 8.8.8.8 nameserver 8.8.4.4 service network restart # restart the network service/etc/init. d/network restart
If not, restart the server: shutdown-R now or reboot.
The network configuration is complete!
Centos 6.0 sets IP addresses, gateways, and DNS