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, if the original file name is centos.txt, then 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.
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.
========================================================== ========================================================== ====
Check that the computer has several NICs:
TerminalCommandEnter the following:
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
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!
Link: http://www.osyunwei.com/archives/423.html