CentOS network configuration (manual setting and automatic retrieval)

Source: Internet
Author: User
The following two methods are used to set up network connections for CentOS configuration (manual setting and automatic retrieval). before setting the network connection, you must back up the network, especially for new users, if there are too many changes, you will also be confused, so it is best to back up (bak) before modifying a file ). Main... the following two methods are used to set up network connections for CentOS configuration (manual setting and automatic retrieval). before setting the network connection, you must back up the network, especially for new users, if there are too many changes, you will also be confused, so it is best to back up (bak) before modifying a file ). Main configuration file:/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network/etc/resolv. conf/etc/hosts restart the network configuration, the configuration takes effect: service network restart 1. modify the file to set network connection 1. the automatic acquisition of IP addresses is related to the automatic acquisition of four files.) /etc/sysconfig/network-scripts/ifcfg-eth0 [zhangy @ localhost network-scripts] $ cat ifcfg-eth0 # Marvell Technology Group Ltd. 88E8039 PCI-E Fast Ethernet Controller DEVICE = eth0 // BOOTPROTO = dhcp started by eth0 // the way to get the IP is automatically obtained, stati C is a fixed IP, none is manual HWADDR = 00: 16: D3: A2: F6: 09 // the physical address of the network adapter IPV6INIT = yes // whether IP6 IPV6_AUTOCONF = yes // whether IP6 automatically configures ONBOOT = yes // whether the network interface is valid at startup B) /etc/sysconfig/network [zhangy @ localhost network-scripts] $ cat/etc/sysconfig/network NETWORKING = yes // whether the network is available NETWORKING_IPV6 = yes HOSTNAME = localhost. localdomain // host name, the host name is configured in/etc/hosts c)/etc/hosts [zhangy @ localhost network-scripts] $ cat/etc/hosts # Do not remove Following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost. localdomain localhost // root/etc/resolv. the search in conf must correspond to localhost. localdomain: 1 localhost6.localdomain6 localhost6 d)/etc/resolv. conf [zhangy @ localhost network-scripts] $ cat/etc/resolv. conf; generated by/sbin/dhclient-script nameserver 192.168.1.1 // search localdomain for the IP address of the DNS server C/hosts: 2. manually set manual settings. you only need to modify three files.) /etc/sysconfig/network [zhangy @ localhost network-scripts] $ cat/etc/sysconfig/network NETWORKING = yes NETWORKING_IPV6 = yes # HOSTNAME = localhost. localdomain // why do you need to comment out the host name? generally, resolve the host name or domain name first, and then dns gateway = 192.168.1.1 // add GATEWAY B) /etc/sysconfig/network-scripts/ifcfg-eth0 [zhangy @ localhost network-scripts] $ cat ifcfg-eth0 # Marvell Technology Group Ltd. 88E8039 PCI-E (Fast) Ethernet Controller DEVICE = eth0 BOOTPROTO = none // start with manual BROADCAST = 192.168.1.255 HWADDR = 00: 16: D3: A2: F6: 09 IPADDR = 192.168.1.108 // ip netmask = 255.255.255.0 // subnet mask NETWORK = 192.168.1.0 255.6init = yes 255.6_autoconf = yes ONBOOT = yes TYPE = Ethernet // network type c) /etc/resolv. conf [zhangy @ localhost network-scripts] $ cat/etc/resolv. conf #; generated by/sbin/dhclient-script # nameserver 192.168.1.1 # search localdoma In nameserver 116.228.111.118 // add the primary DNS nameserver 180.168.20.18 // add the secondary DNS nameserver 8.8.8.8 # Google domain name server nameserver 8.8.4.4 # Google domain name server 2. Command method netconfig, after RH is installed, netconfig will appear in the system. Although centos evolved from RH, No. But it doesn't matter. we may install it ourselves. [Zhangy @ localhost download] $ wget ftp://ftp.nluug.nl/pub/os/Linux/distr/CentOS/5.0/os/i386/CentOS/netconfig-0.8.24-1.2.2.1.i386.rpm [Zhangy @ localhost download] $ rpm-ivh netconfig-0.8.24-1.2.2.1.i386.rpm error: can't create transaction lock on/var/lib/rpm/_ db.000 [zhangy @ localhost download] $ su root // do not forget to use the root account, otherwise the above error password will be reported: [root @ localhost download] # rpm-ivh netconfig-0.8.24-1.2.2.1.i386.rpm Preparing... ######################################## ### [100%] 1: netconfig ####################################### #### [1, 100%] [roo T @ localhost download] # whereis netconfig // Check where netconfig is located. netconfig: /usr/sbin/netconfig 01 [root @ localhost] # netconfig -- help02 -- bootproto = (dhcp | bootp | none) Boot protocol to use // obtain the IP address, dhcp is self-built, bootp fixed IP, none manual 03 -- gateway = STRING Network gateway // specify gateway 04 -- ip = string ip address // specify ip address 05 -- nameserver = STRING Nameserver // specify DNS06 -- netmask = STRING Netmask/ /specify the subnet mask 07 -- hostname = STRING Hostname/ /Specify the host name 08 -- domain = STRING Domain name // specify the domain name 09-d, -- device = STRING Network device // specify Network device 10 -- nodns No DNS lookups // No DNS query 11 -- hwaddr = STRING Ethernet hardware address // specify the physical address of the NIC 12 -- description = STRING Description of the device // Description 13 Help options: 14 -?, -- Help Show this help message15 -- usage Display brief usage message 1. automatically obtain the IP address [root @ localhost download] #/usr/sbin/netconfig-d eth0 -- bootproto = dhcp 2. manually set IP [root @ localhost download] #/usr/sbin/netconfig-d eth0 -- bootproto = none -- ip = 192.168.1.108 -- netmask = 255.255.255.0 -- gateway = 192.168.1.1 -- nameserver = 116.228.111.118 III, some problems encountered in the configuration 1. the restart of the network does not work after the service network restart is restarted, the network still cannot be connected, I can confirm that my configuration is correct. restart 1. Just drop the computer. 2, when backing up the ifcfg-eth0 file to pay attention to, in front of do not carry ifcfg-eth0 I will automatically get the IP address of the configuration file ifcfg-eth0 for a backup, the name is ifcfg-eth0_dhcp, when restarting the network, this file is still executed. at the beginning, I didn't notice this point. when I checked the network in ifconfig, I found that the changes I made were not effective at all, and/etc/resolv. the changes made in conf are covered again. So when backing up, there should be no ifcfg-eth0 in front
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.