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

How to bind Centos7/RHEL7 dual Network Card

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to bind Centos7/RHEL7 dual network cards". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to bind Centos7/RHEL7 dual network cards.

1. Brief

Dual Nic binding technology uses teaming technology in centos7, while bonding technology is used in rhel6/centos7. In centos7, dual Nic binding can use both teaming and bonding. Here, teaming technology is recommended to facilitate viewing and monitoring.

two。 Principle

Here are the two most common binding modes of dual Nic:

(1) roundrobin-polling mode

All links are in a state of load balancing, which increases bandwidth and supports fault tolerance.

(2) activebackup-active / standby mode

One network card is active, the other is in the backup state, and all traffic is processed on the main link. When the active network card down is down, the backup network card is enabled.

3. Basic environment

System: centos7

In centos7, shut down the virtual machine to add the network card, and then turn on the virtual machine, the system will not automatically generate the configuration file of the network card:

The method to generate the Nic configuration file in centos7 is simple, use the following command:

# View physical Nic information [root@localhost ~] # nmcli devdevice type state connection eno16777736 ethernet connected eno16777736 eno33554984 ethernet connected wired connection 1 eno50332208 ethernet connected wired connection 2 lo loopback unmanaged--

As can be seen from the above information, there are a total of four network cards, of which lo is a local loop network card and the other three are physical network cards.

# View the connection information of the network card [root@localhost] # nmcli con shname uuid type device wired connection 2 9a1314bf-d273-406a-930a-dc4160dee4ec 802-3-ethernet eno50332208 wired connection 1 47eef4a3-7fa4-4a73-83ef-1485bda9b950 802-3-ethernet eno33554984 eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736

The above information shows that there are a total of three connections, two of which are wired, indicating a network card connection that has not been set up, and an enoxx connection. Next, modify the naming method of the two wired connections and generate the network card configuration file:

# first of all Delete two useless wired connections [root@localhost ~] # nmcli con del 9a1314bf-d273-406a-930a-dc4160dee4ecconnection 'wired connection 2' (9a1314bf-d273-406a-930a-dc4160dee4ec) successfully deleted. [root@localhost ~] # nmcli con del 47eef4a3-7fa4-4a73-83ef-1485bda9b950connection' wired connection 1' (47eef4a3-7fa4-4a73-83ef-1485bda9b950) successfully deleted.# creates a new connection again and generates the configuration file [root@localhost ~] # nmcli conn add type ethernet con- Name eno50332208 ifname eno50332208 connection 'eno50332208' (eea2a115-63f8-4f33-be84-12559f02542c) successfully added. [root@localhost] # nmcli conn add type ethernet con-name eno33554984 ifname eno33554984connection' eno33554984' (32d2389e-4e82-4419-9d18-5aff8f0be003) successfully added. # finally, check out [root@localhost ~] # nmcli con shname uuid type device eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 eno33554984 32d2389e-4e82-4419-9d18-5aff8f0be003 802-3-ethernet eno33554984 eno50332208 eea2a115-63f8-4f33-be84-12559f02542c 802-3-ethernet eno50332208 [root@localhost ~] # ll / etc/sysconfig/network-scripts/ifcfg-eno*-rw-r--r--. 1 root root 394 nov 26 05:59 / etc/sysconfig/network-scripts/ifcfg-eno16777736-rw-r--r--. 1 root root 288 dec 26 08:44 / etc/sysconfig/network-scripts/ifcfg-eno33554984-rw-r--r--. 1 root root 288 dec 26 08:44 / etc/sysconfig/network-scripts/ifcfg-eno50332208

The network connection and configuration file have been generated successfully. Next, use teaming mode to bind dual network cards through eno33554984 and eno50332208.

4. Roundrobin mode:

Roundrobin mode, also known as polling mode, is based on each packet. When the two network cards of a server are set to roundrobin mode teaming, the packets sent by the server will be polled on the two physical network cards, that is, the first packet takes a network card, and the second packet takes the second network card, polling in turn.

Note:

(1) roundrobin is fault-tolerant. When a network card down is dropped, the packet is still sent successfully.

(2) when using roundrobin mode, you must do an Ethernet channel on the switch, otherwise the network will not be able to connect.

Actual operation:

# use the nmcli command to create team interface team0, and set the teaming mode to roundrobin [root@localhost ~] # nmcli con add type team con-name team0 ifname team0 config'{"runner": {"name": "roundrobin"}} 'connection' team0' (9dc48bd6-54b9-48db-b7dd-ecf34ae9196f) successfully added. # set the ip address to the interface team0 [root@localhost ~] # nmcli con modify team0 ipv4.address' 10.0.0.2 Universe 24' ipv4.gateway '10.0.0.1' # set to manual mode Cancel dhcp [root@localhost ~] # nmcli con modify team0 ipv4.method manual # add two physical network cards to team [root@localhost ~] # nmcli con add type team-slave con-name team0-port1 ifname eno33554984 master team0connection 'team0-port1' (22d3640e-f5c8-499c-b0dd-913c8970d800) successfully added. [root@localhost ~] # nmcli con add type team-slave con-name team0-port2 ifname eno50332208 master team0connection' team0-port2' (12660d2a-0e1f-41e6-96b2-53de4fc6b78c) successfully added . [root@localhost] # nmcli con shname uuid type device team0-port2 12660d2a-0e1f-41e6-96b2-53de4fc6b78c 802-3-ethernet-- eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0-port1 22d3640e-f5c8-499c-b0dd-913c8970d800 802-3-ethernet-- team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team team0 eno33554984 32d2389e-4e82-4419-9d18-5aff8f0be003 802-3-ethernet eno33554984 eno50332208 eea2a115- 63f8-4f33-be84-12559f02542c 802-3-ethernet eno50332208 # View the status of team0 [root@localhost ~] # teamdctl team0 stsetup: runner: roundrobin

4.1 troubleshooting roundrobin problems

The first time you look at the result, check the configuration:

# by directly viewing the network card, we found that team0 did not start [root@localhost ~] # ip a | grep team05: team0: mtu 1500 qdisc noqueue state down # using ifup to start team0 is not successful. Continue to check [root@localhost ~] # ifup team0 [root@localhost ~] # ip a | grep team05: team0: mtu 1500 qdisc noqueue state down

Direct sysetmctl restart network did not succeed either.

# found that team0-port1 team0-port2 did not add a physical Nic successfully. What happened? [root@localhost] # nmcli con shname uuid type device team0-port2 ec96c1e1-d268-4ba1-a2f9-0133a9f02655 802-3-ethernet-- eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0-port1 22d3640e-f5c8-499c-b0dd-913c8970d800 802-3-ethernet-- team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team team0 eno33554984 32d2389e-4e82-4419-9d18-5aff8f0be003 802-3-ethernet eno33554984 eno50332208 eea2a115-63f8 -4f33-be84-12559f02542c 802-3-ethernet eno50332208 # delete [root@localhost] # nmcli con del team0-port1connection 'team0-port1' (22d3640e-f5c8-499c-b0dd-913c8970d800) successfully deleted. [root@localhost ~] # nmcli con del team0-port2connection' team0-port2' (ec96c1e1-d268-4ba1-a2f9-0133a9f02655) successfully deleted. # remove the connection between two physical network cards [root@localhost] # nmcli con shname uuid type device eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team team0 eno33554984 32d2389e-4e82-4419-9d18-5aff8f0be003 802-3-ethernet eno33554984 eno50332208 eea2a115-63f8-4f33-be84-12559f02542c 802-3-ethernet eno50332208 [root@localhost ~] # nmcli con del eno33554984 eno50332208connection 'eno33554984' ( 32d2389e-4e82-4419-9d18-5aff8f0be003) successfully deleted.connection 'eno50332208' (eea2a115-63f8-4f33-be84-12559f02542c) successfully deleted. # deleted successfully [root@localhost ~] # nmcli con shname uuid type device eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team team0 # add two physical NICs to team [root@localhost ~] # nmcli con add type team-slave con-name team0-port1 ifname eno33554984 master team0connection 'team0-port1' (0331ea43-95c0-4106-b388-8484d4c3940d) again Successfully added. [root@localhost ~] # nmcli con add type team-slave con-name team0-port2 ifname eno50332208 master team0connection 'team0-port2' (880f2146-fe93-42dd-8d28-7d0dd50b4011) successfully added. [root@localhost ~] # nmcli con shname uuid type device team0-port1 0331ea43-95c0-4106-b388-8484d4c3940d 802-3-ethernet eno33554984 eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team Team0 team0-port2 880f2146-fe93-42dd-8d28-7d0dd50b4011 802-3-ethernet eno50332208

Now you have successfully bound two physical network cards to the team group.

# now you can see the status of team0. The mode is: roundrobin [root@localhost ~] # teamdctl team0 st setup: runner: roundrobinports: eno33554984 link watches: link summary: up instance [link _ watch_0]: name: ethtool link: up down count: 0 eno50332208 link watches: link summary: up instance [link _ watch_0]: name: ethtool link: up down count: 0

In this way, the roundrobin of team mode is built successfully.

Summary:

When doing link aggregation, the physical Nic to be used cannot be connected independently, that is, when viewed by nmcli con sh, it cannot exist independently, otherwise it cannot be bound to team mode.

4.2 Test

Because this is a virtual machine environment, it can only be viewed through the down network card.

[root@localhost ~] # teamdctl team0 stsetup: runner: roundrobinports: eno33554984 link watches: link summary: up instance [link _ watch_0]: name: ethtool link: up down count: 0 eno50332208 link watches: link summary: up instance [link _ watch_0]: name: ethtool link: up down count: 0

Two network cards are online at the same time, and now down has lost one of them.

[root@localhost ~] # nmcli con del team0-port1connection 'team0-port1' (0331ea43-95c0-4106-b388-8484d4c3940d) successfully deleted. [root@localhost ~] # nmcli con shname uuid type device eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0 9dc48bd6-54b9-48db-b7dd-ecf34ae9196f team team0 team0-port2 880f2146-fe93-42dd-8d28-7d0dd50b4011 802-3-ethernet eno50332208 [root@localhost ~] # teamdctl team0 stsetup: Runner: roundrobinports: eno50332208 link watches: link summary: up instance[link _ watch_0]: name: ethtool link: up down count: 0

In this way, it is found that the eno33554984 network card has been dropped by down.

[root@localhost ~] # nmcli con add type team-slave con-name team0-port1 ifname eno33554984 master team0connection 'team0-port1' (59acd6bf-affc-4994-a050-83c45816859a) successfully added. [root@localhost ~] # [root@localhost ~] # teamdctl team0 stsetup: runner: roundrobinports: eno33554984 link watches: link summary: up instance [link _ watch_0]: name: ethtool link: up down count: 0 eno50332208 link watches: link summary: up instance [link _ watch_0]: Name: ethtool link: up down count: 0

The virtual machine environment is tested in this way, while the production environment is directly unplugged and tested by ping.

It is said that roundrobin under linux has the effect of fault tolerance. In order to test whether it has the effect of fault tolerance, the virtual machine makes the following changes to verify:

This time, the network cards are all changed to bridge mode, in order to better test whether it is fault-tolerant.

Roundrobin has been configured. Next, we down a network card to check whether it is fault-tolerant.

Through virtual machine testing, fault tolerance exists.

5. Implementation of binding activebackup with double Network Card

[root@localhost] # nmcli con sh name uuid type device team0-port2 2a1aa534-e021-4452-bb0a-2002dabcbc08 802-3-ethernet eno50332208 team0-port1 9a10c9ef-ee9c-4151-9a47-59b4668e8934 802-3-ethernet-eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 team0 c2278f3f-5c6b-4e1d-b925-514d3c3832b6 team team0 [root@localhost] # nmcli con del team0 team0-port1 team0-port2connection 'team0' (c2278f3f-5c6b-4e1d-b925-514d3c3832b6) successfully deleted.connection 'team0-port1' (9a10c9ef-ee9c-4151-9a47-59b4668e8934) successfully deleted.connection' team0-port2' (2a1aa534-e021-4452-bb0a-2002dabcbc08) successfully deleted. [root@localhost ~] # nmcli con sh name uuid type device eno16777736 51d00668-2cf5-41da-ad8d-5019d62e98ad 802-3-ethernet eno16777736 # delete roundrobin mode Return to the original state. # add logical Nic team0 And enable activebackup mode [root@localhost ~] # nmcli con add type team con-name team0 ifname team0 config'{"runner": {"name": "activebackup"}} 'connection' team0' (f0794e59-419d-4c2a-96b9-464610b6321a) successfully added.# bind ip [root@localhost ~] # nmcli con modify team0 ipv4.address 192.168.118.122 nmcli con modify team0 ipv4.method manual# to add physics Nic to activebackup mode [root@localhost ~] # nmcli con add type team-slave con-name team0-port1 ifname eno33554984 master team0connection 'team0-port1' (52656904-6e85-4a04-98b4-2b19773fa290) successfully added. [root@localhost ~] # nmcli con add type team-slave con-name team0-port2 ifname eno50332208 master team0connection' team0-port2' (44d96e3a-014a-481f-9122-4ca2d3be9f7a) successfully added. [root@localhost ~] # teamdctl team0 stsetup: runner: activebackupports: eno33554984 link watches: link summary: up instance [link_watch_0]: name: ethtool link: up down count: 0 eno50332208 link watches: link summary: up instance[link _ watch_0]: name: ethtool link: up down count: 0runner: active port: eno33554984

Successful. The active Nic is eno33554984.

5.1 Test

Test whether the network is still connected by dropping the active network card through down

The test was successful.

Note: when binding a network card, if you find that the physical network card cannot always be bound to team0, please check whether the physical network card is in up state.

At this point, I believe you have a deeper understanding of "how to bind Centos7/RHEL7 dual network cards". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report