Network Configuration for centos 6 and 7

Source: Internet
Author: User

Network Configuration for centos 6 and 7

As centos7 has changed with the previous release, and the network attribute has changed a lot, the network configuration before centos7 and 7 is explained here separately.

1. Related configuration files
In RHEL, CentOS, and other Redhat Linux systems, the main network-related configuration files are as follows:

/Etc/host. conf configure the control file of the Domain Name Service Client
/Etc/hosts ing host names to IP addresses
The configuration file of the/etc/resolv. conf Domain Name Service client, used to specify the location of the Domain Name Server
/Etc/sysconfig/network contains the most basic network information of the host for system startup.
/Etc/sysconfig/network-script/Some network Information initialized at system startup
/Etc/xinetd. conf defines the network service started by the super process xinetd.
/Etc/networks maps domain names to network addresses
/Etc/protocols sets the protocol used by the host and the protocol numbers of each Protocol
/Etc/services: Set network services with different ports on the host

Ii. Detailed description of the configuration file

1. IP, MASK, GW, and DNS configuration files:/etc/sysconfig/network-scripts/ifcfg-IFACE

DEVICE =: the name of the associated DEVICE, which must be consistent with the "INTERFACE_NAME" in the second half of the file name; BOOTPROTO = {satic | none | dhcp | bootp}: Boot Protocol. To use a static address, use static or none. dhcp indicates that the dhcp server is used to obtain the address; IPADDR =: IP address; NETMASK =: subnet mask; GATEWAY =: Set the default GATEWAY; ONBOOT =: whether to automatically activate this network interface at startup; HWADDR =: hardware address, which must be consistent with the address in the hardware; save; USERCTL={ yes | No}: whether normal users are allowed to control this interface; PEERDNS={ yes | No}: whether to accept the dns address specified by the dhcp server when BOOTPROTO is dhcp;

How to configure the configuration file:

USERCTL: whether normal users can control this device; PEERDNS: If the BOOTPROTO value is "dhcp", whether to allow the dns server allocated by dhcpserver to directly overwrite the information /etc/resolv . Conf file;

Note: After the configuration file is configured, restart the service to take effect.

2. route-related configuration file:/etc/sysconfig/network-scripts/route-IFACE

Two styles:

(1)TARGETviaGW (2) define a route for each three rows ADDRESS #=TARGET NETMASK #=mask GATEWAY #=GW

3. Configure multiple addresses for the NIC:

ifconfig : ifconfig IFACE_ALIAS ip ipaddradd

Configuration file:

ifcfg-IFACE_ALIAS DEVICE=IFACE_ALIAS

Note: The Gateway alias cannot be guided using the dhcp protocol;

4. Linux Network attribute graphical Configuration tool tui (textuserinterface ):

System-config-network-tui. You can also use setup to find the network configuration;

Note: Remember to restart the network service to make it take effect;

5. Configure the Host Name of the current host:

1>. hostname [HOSTNAME] /etc/sysconfig/network 2>.HOSTNAME=

6. The network interface identifies and names the related udev configuration file:

/etc/udev/rules .d /70-persistent-net .rules

7. Uninstall the NIC Driver:

modprobe-re1000

Iii. CentOS7 network attribute Configuration

1. Traditional name: Ethernet eth [0, 1, 2,...], wlan [0, 1, 2,...]

2. udev supports multiple naming schemes:

Firmware, topology

3. Nic naming mechanism

Systemd naming for network devices:

(A) if the index information provided by the Firmware or BIOS integration device on the master board is available and predictable, name the index, for example, eno1; (B) if the index information provided by Firmware or BIOS for the PCI-E expansion slot is available and predictable, name the index, such as ens1; (C) if the physical location information of the hardware interface is available, name it, for example, enp2s0; (D) If you start the service explicitly, you can also name it based on the MAC address, enx2387a1dc56; (E) If none of the above are available, the traditional naming mechanism is used; Some of the above naming mechanisms require the participation of the biosdevname program;

4. Name format

en:ethernet wl:wlan ww:wwan Name type: O <index>: The device index Number of the Integrated Device; S <slot>: Index Number of the expansion slot; X <MAC>: MAC address-based naming; p<bus>s<slot>:enp2s1

5. Nic device naming process:

Step 1: udev, auxiliary tool Program /lib/udev/rename_device , /usr/lib/udev/rules .d /60-net .rules Step 2: biosdevname /usr/lib/udev/rules .d /71-biosdevname .rules Step 3: Check the network interface device according /usr/lib/udev/rules .d /75-net-description ID_NET_NAME_ONBOARD,ID_NET_NAME_SLOT,ID_NET_NAME_PATH

6. Return to the traditional naming method:

(1) Edit /etc/default/grub Configuration File GRUB_CMDLINE_LINUX= "net.ifnames=0rhgbquiet" (2) generate its configuration file for grub2 grub2-mkconfig-o /etc/grub2 .cfg (3) restart the system init6

7. Address Configuration tool: nmcli

nmcli[OPTIONS]OBJECT{COMMAND|help} device-showandmanagenetworkinterfaces connection-start,stop,andmanagenetworkconnections

8. How to modify attributes such as IP addresses:

#nmcliconnectionmodifyIFACE[+|-]setting.propertyvalue setting.property: ipv4.addresses ipv4.gateway ipv4.dns1 ipv4.method manual

9. Network Interface Configuration tui tool: nmtui

10. Host Name Configuration tool: hostnamectl

status set - hostname

4. Different network configurations of Centos7 and earlier releases

1. Different startup Methods

Previous versions: /etc/init .d /network/ start|status|stop|restart Servicenetworkstart|status|stop|restart Centos7:systemctlstart|status|stop|restartnetwork.service

2. Different network interface naming methods

Earlier versions: eth0, 1, 2 ...... Centos7:enoxxxxxxxx

3. Some configuration files are different.

4. Similarities: The methods for modifying the configuration file when setting static addresses are the same.

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.