About Network configuration Management

Source: Internet
Author: User
Tags dns2 get ip

Network management

Configuring IP often uses this configuration file, first we define the path as an alias
Two frequently used commands:
[Email protected] ~]# cd/etc/sysconfig/network-scripts/
[[email protected] ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0 "


Then edit the configuration file
[[email protected] ~]# vim. BASHRC
Alias cdnet= "cd/etc/sysconfig/network-scripts/"
Alias editnet= "Vim/etc/sysconfig/network-scripts/ifcfg-eth0"
WQ disk

Load configuration file takes effect
[Email protected] ~]#. . BASHRC

Changing the configuration file requires a restart of the network service to take effect
[Email protected] ~]# service network restart

State
[[Email protected] ~]# service NetworkManager status

Stop Service
[[Email protected] ~]# service NetworkManager stop

Set up service for next boot not start
[Email protected] ~]# Chkconfig NetworkManager off


Take a look at the corresponding function
[[email protected] ~]# Editnet (note that this is an alias)
Device=eth0 (the name of the network adapter to which this profile is associated)
Bootprroto=yes (yes auto get IP none disable auto get IP)
Hwaddr=00:0c:29:d4:96:b6 (the MAC address of the network card, this address should be consistent with the fixed address in the NIC device ROM)
Type=ethernet (type of device, usually Ethernet,bridge)
UUID=EC6EE114-7F60-4E7E-A1FE-9F6BFCB884C3 (unique identifier of the NIC device)
Onboot=yes (whether this device is activated with OS boot)
ipaddr=10.1.1.65 (IP address of this interface, manually specified, of course automatically gets another option)
netmask=255.255.255.0 (Subnet mask)
Prefix=16 (Subnet mask ibid.)
gatewat=10.1.1.254 (Gateway)
dns1=8.8.8.8 (the primary DNS server that the DNS server points to)
dns2=114.114.114.114 (Alternate DNS server address)
dns3=8.8.4.4 (Third alternate DNS server address)
Peerdns=yes (when the value of Bootproto is DHCP ' auto get dynamic IP ',
Whether to allow the DNS service provided by the DHCP server to point to a DNS server that overrides local manual configuration point to Yes automatic IP overwrite no not allowed)

Restart the network service after configuring the file
[[Email protected] ~]# service NetworkManager start
Set Network Parameters ... Determine
Starting NetworkManager daemon: [OK]

Manually configure a simple, rough IP
[[email protected] ~]# Editnet (Note that this is the alias of the configuration file)
Device=eth0 (the name of the network adapter to which this profile is associated)
BOOTPROTO=DHCP (Auto Get IP)
Then restart the system to take effect reboot
==============================================================================
Implement a network adapter to bind multiple IPs
Useful for Virtual hosts
Bind multiple IP addresses to a network card
Generate a separate interface profile for each device alias
Required to close NetworkManager service first
Alias format: ifcfg-ethx:xxx
Must use static networking

Nic Aliases
[Email protected] ~]# cdnet
[email protected] network-scripts]# CP Ifcfg-eth0 ifcfg-eth0:1
[email protected] network-scripts]# CP Ifcfg-eth0 Ifcfg-eth0:2

Edit definition alias Nic interface etho:1
[Email protected] network-scripts]# vim ifcfg-eth0:1
Device=eth0:1 Note name to change
ipaddr=10.1.65.1 IP to be changed
Prefix=16 Mask
gateway=10.1.1.254 Gateway
dns1=8.8.8.8 DNS

Edit definition alias Nic interface etho:2
[Email protected] network-scripts]# vim Ifcfg-eth0:2
Device=eth0:2 Note name to change
ipaddr=10.1.65.2 IP to be changed
Prefix=16 Mask
gateway=10.1.1.254 Gateway
dns1=8.8.8.8 DNS

Restart service after editing
[Email protected] network-scripts]# service network Restar
[Email protected] network-scripts]# ifconfig
View IP this time the original IP can be used, the CP two IP can also be three available IP

The following implementation of both the automatic acquisition of IP and can use static IP
[[email protected] network-scripts]# vim Ifcfg-eth0 Edit Master Profile
Device=eth0
BOOTPROTO=DHCP Plus auto Get IP The IP added above can also be used
[[Email protected] network-scripts]# service network restart Restart services
This time is already two static IP an automatically acquired IP
==============================================================================
See below the multi-NIC binding an IP
Network Interface Configuration Bonding
is to bind multiple network cards to the same IP address to provide services externally, can achieve high availability or load balancing.
Of course, it is not possible to set up the same IP address directly for two network cards, through the bonding, virtual one card to provide external connection,
The physical NIC is modified to the same MAC address
Add a NIC to the virtual machine and let's look at the ifconfig-a view all NIC interfaces include inactive just added on the

Create a configuration file for a bonding device
[Email protected] network-scripts]# vim ifcfg-bond0
Devier=bond0
ipaddr=10.1.65.66
Prefix=16
gateway=10.1.0.1
dns1=8.8.8.8
bonding_opts= "Miimon=100 mode=1"

Edit Nic Eth0
[Email protected] network-scripts]# vim Ifcfg-eth0
Device=eth0
Slave=yes physical Nic Eth0 is a Slave
Master=bond0 Bond0 is the host that provides the current profile information

CP eth0 files to a new file eth1
[email protected] network-scripts]# CP Ifcfg-eth0 IFCFG-ETH1
[Email protected] network-scripts]# Vim ifcfg-eth1 edit eth1
Device=eth1 name must be changed, just copied over, is 0 to change to another
Slave=yes
Master=bond0

See if the content is correct after configuration is complete
[email protected] network-scripts]# cat ifcfg-eth*
Device=eth0
Slave=yes
Master=bond0
Device=eth1
Slave=yes
Master=bond0
[email protected] network-scripts]# cat ifcfg-bond0
Device=bond0
ipaddr=10.1.65.65
Prefix=16
gateway=10.1.0.1
dns1=8.8.8.8
bonding_opts= "Miimon=100 mode=1"

Next Restart service takes effect
[Email protected] network-scripts]# service network restart

[Email protected] network-scripts]# ifconfig
MAC address is the same
The current primary NIC is eth0
If eth0 off the net, another eth1 start to take over the run

CentOS 7 Network configuration
Onboot: Whether this device is activated at system boot time
Type: interface types; common Ethernet, Bridge.
UUID: Unique identification of the device
IPADDR: Specify IP Address
NETMASK: Subnet Mask
Gateway: Default Gateways
DNS1: The first DNS server points to a
DNS2: The second DNS server points to a
Userctl: Whether a normal user can control this device
Peerdns: If the value of Bootproto is "DHCP", whether to allow DHCP server to assign a DNS server to direct the information to overwrite the/etc/resolv.conf file

For the convenience of the experimental environment, the name of the network card is changed because it is too long, not very convenient, recommended work environment do not modify
Use traditional naming methods:

1 Editing the/etc/default/grub configuration file
grub_cmdline_linux= "RHGB quiet net.ifnames=0"

[Email protected] ~]# Vim/etc/default/grub
grub_cmdline_linux= "Crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quieti net.ifnames=0"


Generate its configuration file for Grub2
Grub2-mkconfig-o/etc/grub2.cfg Soft Connection
[[email protected] ~]# Grub2-mkconfig-o/boot/grub2/grub.cfg True Path


2 Modify/boot/grub2/grub.cfg This is a soft connection is not recommended to use the above
[[email protected] ~]# vim/boot/grub2/grub.cfg Modify profile search keyword: linux16 match to the first character of the field trailing append net.ifnames=0
linux16/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro Crashkernel=auto rd.lvm.lv=centos/root Rd.lvm.lv=centos/swap RHGB quiet LANG=ZH_CN. UTF-8 net.ifnames=0


3 then reboot reboot the system
Ifconfig view this time the NIC name has changed to Eth0;1
But the file name inside the NIC configuration file is still not notconsistent

Move the original file to a new file and name it eth0
[Email protected] network-scripts]# MV ifcfg-eno16777736 Ifcfg-eth0

Modify the contents of a moved configuration file.
[Email protected] network-scripts]# vim Ifcfg-eth0
Device= "Eth0" The original device name is long format, after the successful modification is eth0

There is only one profile for the dual NIC, and the eth1 configuration file needs to be created
[email protected] network-scripts]# CP Ifcfg-eth0 IFCFG-ETH1
[Email protected] network-scripts]# vim ifcfg-eth1
Device= "eth1" to modify the device name eht1

[[email protected] ~]# systemctl Restart Network Restart service

Configure Linux Network properties: IP command
View Network card devices
IP link

Set eht1 down disable
[[Email protected] ~]# IP link set eth1 down or use ifconfig eth1 down

Set eht1 up enabled
[[Email protected] ~]# IP link set eth1 up or use ifconfig eth1 UO

Network card alias Temporary change restart is invalid
Command line interface
[Email protected] ~]# ifconfig eth1 10.1.0.1/24
[Email protected] ~]# ifconfig eth1:100 10.1.0.2/24

IP command:
IP addr Add 172.16.1.2/16 dev eth0
IP addr Add 172.16.1.1/16 dev eth0 label eth0:0
IP addr Add 172.16.1.2/16 dev eth0 label eth0:0
IP addr del 172.16.1.1/16 dev eth0 label eth0:0
IP addr Flush Dev eth0 label eth0:0


Address Configuration Tool: Nmcli
[[email protected] ~]# NMCLI connection show says include inactive links
[[email protected] ~]# NMCLI connection show--active Show only active links
[[email protected] ~]# NMCLI device show {eth0 name} Display Network interface properties

[[email protected] ~]# Systemctlrestart Network Restart Service
[[email protected] ~]# nmcli con Reload effective configuration file

[Email protected] ~]# NMCLI connection Add con-name Home type Ethernet ifname eth1 autoconnect Yes IP4 10.1.100.100/24 GW 4 10.1.0.1
Con-name Home: Name Type Ethernet: TYPE ifname eth1: Nic name AutoConnect yes: Boot up ip4 10.1.100.100/24 gw4 10.1.0.1 Configure address/24 Mask Gateway

[[email protected] ~]# NMCLI connection up home interface enabled
[[email protected] ~]# nmcli con del home Delete connection

Modify Connection Settings
[[email protected] ~]# nmcli con mod static connection.autoconnectno
[[email protected] ~]# nmcli con mod static ipv4.dns 172.25.x.254
[[email protected] ~]# nmcli con mod static +ipv4.dns 8.8.8.8
[[email protected] ~]# nmcli con mod static-ipv4.dns 8.8.8.8
[[email protected] ~]# nmcli con mod static ipv4.addresses "172.25.x.10/24 172.25.x.254"
[[email protected] ~]# nmcli con mod static +ipv4.addresses 10.10.10.10/24


Correspondence relationship
Nmclicon MoD ifcfg-* file
Ipv4.method Manual Bootproto=none
Ipv4.method Auto Bootproto=dhcp
Ipv4.addresses "192.0.2.1/24 ipaddr0=192.0.2.1
192.0.2.254 "prefix0=24
gateway0=192.0.2.254
Ipv4.dns 8.8.8.8 dns0=8.8.8.8
Ipv4.dns-search example.com domain=example.com
Ipv4.ignore-auto-dns true Peerdns=no
Connection.autoconnectyes Onboot=yes
Connection.id eth0 Name=eth0
Connection.interface-name eth0 Device=eth0
802-3-ethernet.mac-address ... Hwaddr= ...

Device configuration is saved in a text file
/etc/sysconfig/network-scripts/ifcfg-<name>
Configure static configuration dynamically
Device=ethx Device=ethx
Hwaddr=0:02:8a:a6:30:45 hwaddr=0:02:8a:a6:30:45
Bootproto=dhcp ipaddr=192.168.0.123
Onboot=yes netmask=255.255.255.0
Type=ethernet gateway=192.168.0.254
Onboot=yes
Type=ethernet

After you modify the connection configuration, you need to reload the configuration
Nmcli Con Reload
Nmcli con Down "system eth0" can be activated automatically
Nmcli con up "system eth0"
nmcli Dev dis eth0 disable nic, check-in is automatically activated


Networking Group Network Teaming
Network group: Is the method of aggregating multiple network cards together to achieve redundancy and increase throughput
Network group differs from legacy bonding technology for better performance and scalability
Network groups are implemented by kernel-driven and TEAMD daemons
Multiple ways runner

Starting the Network group interface does not automatically start the port interface in the network group
The port interface in the Start Network group interface does not automatically start the Network group interface
Disabling the network group interface automatically disables the port interface in the network group
A network group interface without a port interface can initiate a static IP connection
When DHCP connection is enabled, network groups that do not have a port interface wait for the port interface to join

Create a network group interface
[[email protected] ~]# nmcli connection Add con-name team0 type team ifname team0 config ' {"runner": {"name": "Activebackup" }}‘
[Email protected] ~]# NMCLI connection Modify TEAM0 ipv4.addresses 10.1.7.65/16
[Email protected] ~]# NMCLI connection modify TEAM0 Ipv4.method manual
[Email protected] ~]# NMCLI connection Modify Team0 ipv4.dns 8.8.8.8 Ipv4.gateway 10.1.0.1
[Email protected] ~]# nmcli connection add con-name tem0-eth0 type Team-slave ifname eth0 master Team0
[Email protected] ~]# nmcli connection add con-name tem0-eth1 type Team-slave ifname eth1 master Team0
[Email protected] ~]# NMCLI connection up Team0
[Email protected] ~]# NMCLI connection up Team0-eth0
[Email protected] ~]# NMCLI connection up team0-eth1



This article from "Pony Brother Linux system operation and Maintenance" blog, reproduced please contact the author!

About Network configuration Management

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.