Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux Network Management (7) implementation of team Group in centos7

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Linux Network Management (7) implementation of team Group in centos7

In linux, centos7 used to use bond mechanism to bind multiple networks to the same IP address to provide access to the network, and according to different modes to load balance or reincarnation management to process data. After arriving at contos7, a powerful tool, nmcli tool command, is provided. Using this tool, specific configuration files will be regenerated according to the configuration of command parameters for use by network interfaces, which is convenient and flexible. Instead of using the bond mechanism to define linux, it uses the network group team mechanism to treat the team group as a device. Let's say through a case.

Team group case of active / standby mode:

Environment View:

Here, operate the linux system in the VM virtual machine

# the 3.10 linux kernel is used here

[root@mzf] # uname-r3.10.0-327.el7.x86_64

# using CentOS 7.2 release

[root@mzf ~] # cat / etc/redhat-release CentOS Linux release 7.2.1511 (Core)

View the network card:

[root@mzf ~] # ip-o link show up | awk-fills:''{print $2} 'loeth0eth2 [root@mzf ~] # ip link show up

Note: except for the lo local network loopback device, this machine has two enabled network cards: eth0 and eth2.

Create a team netgroup:

# create a team device named team0 and use the active / slave mode:

[root@mzf ~] # nmcli connection add con-name team0 type team ifname team0 config'{"runer": {"name": "activebackup"} 'Connection' team0' (b9f8fdcc-8682-4b2e-bdc1-3eda2aef70d3) successfully added.

# set IP, gateway and other information of team0 group:

1. When setting the ip address acquisition method, you can enter a command that does not exist to get help.

[root@mzf] # nmcli connection modify team0 ipv4.addresses 10.1.250.111 ipv4.method helpError 16 ipv4.gateway 10.1.0.1 ipv4.method helpError: failed to modify ipv4.method: 'help' not among [auto, link-local, manual, shared, disabled].

2. From the above, we found 5, where manual is the static IP address, so set method to manual

[root@mzf ~] # nmcli connection modify team0 ipv4.addresses 10.1.250.111 ipv4.gateway 16 ipv4.gateway 10.1.0.1 ipv4.method manual

3. Check whether the team0 device connection has been created

[root@mzf] # nmcli connection show NAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0 team0 b9f8fdcc-8682-4b2e-bdc1-3eda2aef70d3 team team0 System eth2 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 802-3-ethernet eth2

Note: team0 is the device just created, team is represented as a netgroup device, and the configuration of the two network cards is identified by the nmcli tool.

4. Check the ip acquisition mode of team0:

[root@mzf ~] # nmcli connection show team0 | grep-A 4'^ ipv4\ .method'ipv4.method: manual # here indicates that static IP is used to obtain ipv4.dns: # DNSipv4.dns-search: ipv4.addresses: 10.1.250.111 / is not specified when it is created 16 # IP address ipv4.gateway: 10.1.0.1 # specified gateway

5. Check whether the configuration file is automatically generated

[root@mzf network-scripts] # ls-l / etc/sysconfig/network-scripts/ifcfg-team0-rw-r--r--. 1 root root 349 Sep 7 00:50 / etc/sysconfig/network-scripts/ifcfg-team0

Parsing: this configuration file records some information about the team0 device in the same format as the previous Ethernet Nic configuration information.

Add designated Ethernet Nic devices to the team0 to form a network group

# join the eth0 device to the team0 network group and set the slave device name to team0-eth0

[root@mzf network-scripts] # nmcli connection add con-name team0-eth0 type team-slave autoconnect no ifname eth0 master team0 Connection 'team0-eth0' (5e3d9d5c-934c-448f-8fc6-ab3b4371e812) successfully added.

# join the eth2 device to the team0 network group and set the slave device name to team0-eth2

[root@mzf network-scripts] # nmcli connection add con-name team0-eth2 type team-slave autoconnect no ifname eth2 master team0 Connection 'team0-eth2' (bbb9bfe0-55df-4fe4-9d13-27535a4bb206) successfully added

# check whether the network group subnet card configuration file is automatically generated

[root@mzf network-scripts] # ls-l / etc/sysconfig/network-scripts/ifcfg-team0*-rw-r--r--. 1 root root 349 Sep 7 00:50 / etc/sysconfig/network-scripts/ifcfg-team0-rw-r--r--. 1 root root 118 Sep 7 01:03 / etc/sysconfig/network-scripts/ifcfg-team0-eth0-rw-r--r--. 1 root root 118 Sep 7 01:04 / etc/sysconfig/network-scripts/ifcfg-team0-eth2

# check the list of device connections again

[root@mzf network-scripts] # nmcli connection showNAME UUID TYPE DEVICE team0-eth2 bbb9bfe0-55df-4fe4-9d13-27535a4bb206 802-3-ethernet-System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0 team0-eth0 5e3d9d5c-934c-448f-8fc6-ab3b4371e812 802-3-ethernet-- team0 b9f8fdcc-8682-4b2e-bdc1-3eda2aef70d3 team Team0 System eth2 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 802-3-ethernet eth2

Parsing: it seems that eth0 and eth2 are not successfully bound to the team0 group. This is because according to the mechanism defined by the nmcli tool, the same device can only be bound in the same configuration, that is, to read the configuration in the specified configuration files (ifcfg-eth0, ifcfg-eth2). So at this point, you can disconnect the original link configuration of eth0 and eth2.

Activate team0 netgroup members

# disconnect the original eth0 link

[root@mzf network-scripts] # nmcli device disconnect eth0

# enable team0-eth0 netgroup devices

[root@mzf network-scripts] # nmcli connection up team0-eth0

# disconnect the original eth2 link

[root@mzf network-scripts] # nmcli device disconnect eth2

# enable team0-eth2 netgroup devices

[root@mzf network-scripts] # nmcli connection up team0-eth2

# check the link again

Parsing: at this time, both eth2 and eth0 have been recognized as member devices in team0, while the previous default network card configuration and lost the binding relationship with the network card.

Determine the connectivity of the network

# check the Ip address of team0 device

Ip addr show

Resolution: here, eth0 and eth2 have been bound together to become sub-members of the team0 network group, using the 10.1.250.111 address.

# View team0 routing table and gateway

Resolution: here, because the two network cards are identified as team0 network group devices, only a single device is recorded in the routing table. No matter when the data is received, it is identified through the routing table in the network group.

Test of active / standby mode:

# View the current usage status of team0

[root@mzf ~] # teamctl team0 state

# disconnect eth0. Virtual machines are used here, so click the corresponding network card in the lower right corner to "disconnect". After disconnecting, the picture turns gray.

# check the status again

Parsing: originally it was all up, but now eth2 is enabled, while eth0 is disconnected, and shows that the number of disconnections is 1.

# enable eth0 again

# check team0 status again

Parsing: they are all enabled now, but of course, if they are all disconnected, then team0 is equivalent to no active state members, and it loses its meaning.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report