CN114629744B - Data access method, system and related device based on macvlan host network - Google Patents

Data access method, system and related device based on macvlan host network Download PDF

Info

Publication number
CN114629744B
CN114629744B CN202210088952.8A CN202210088952A CN114629744B CN 114629744 B CN114629744 B CN 114629744B CN 202210088952 A CN202210088952 A CN 202210088952A CN 114629744 B CN114629744 B CN 114629744B
Authority
CN
China
Prior art keywords
interface
virtual logical
eth
macvlan
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210088952.8A
Other languages
Chinese (zh)
Other versions
CN114629744A (en
Inventor
梅盛鑫
江文龙
高伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202210088952.8A priority Critical patent/CN114629744B/en
Publication of CN114629744A publication Critical patent/CN114629744A/en
Application granted granted Critical
Publication of CN114629744B publication Critical patent/CN114629744B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4641Virtual LANs, VLANs, e.g. virtual private networks [VPN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4604LAN interconnection over a backbone network, e.g. Internet, Frame Relay
    • H04L12/462LAN interconnection over a bridge based backbone
    • H04L12/4625Single bridge functionality, e.g. connection of two networks over a single bridge

Abstract

The application discloses a data access method, a system and a related device based on a macvlan host network. The data access method based on the macvlan host network comprises the following steps: creating a virtual logic vlan interface by taking a physical interface of a server as a father interface; creating a macvlan child interface by taking the virtual logical vlan interface as a parent interface; creating a first virtual logical eth interface in a container of the server by taking a macvlan child interface as a parent interface, so that the first virtual logical eth interface is associated with a virtual network card in the container; receiving an access instruction of accessing a macvlan sub-interface associated with the virtual network card by the virtual network card; responding to the virtual network card based on the access instruction through a parent interface of the first virtual logical eth interface associated with the virtual network card. By the scheme, the first virtual logical eth interface on the container side can directly access the macvlan sub-interface on the server side, and network intercommunication between the first virtual logical eth interface and the father interface is realized.

Description

Data access method, system and related device based on macvlan host network
Technical Field
The present disclosure relates to the field of container networks, and in particular, to a data access method, system and related device based on a macvlan host network.
Background
Compared with the defects of the traditional virtualization technology, such as huge cost, redundant deployment and slow operation, the current containerization technology is developed suddenly and rapidly, and is widely applied to various fields of industrial production; however, a key area of the containerization technology is a network architecture, the container cloud network depends on a plurality of components, most of these components are components of kubernetes (K8 s for short, google open-source container cluster management system, providing functions of application deployment, maintenance, expansion mechanism and the like) architecture, kubernetes are a huge open-source container orchestration technology, small enterprises are often limited by factors such as manpower, financial resources and the like, and a robust container network is highly expected to be built by a kernel based on a linux operating system, and a macvlan module of the linux kernel is a low-cost choice, but the macvlan itself has its own limitation, such as a child interface cannot access a parent interface, if the macvlan is used for directly connecting a container, and the container network often has certain limitations and cannot meet corresponding scenes.
Disclosure of Invention
The technical problem to be solved mainly is to provide a data access method, a system and a related device based on a macvlan host network, which can enable a first virtual logical eth interface at a container side to directly access a macvlan sub-interface at a server side, and realize network intercommunication between the first virtual logical eth interface and a father interface in a bridging mode.
In order to solve the above-mentioned problems, a first aspect of the present application provides a data access method based on a macvlan host network, where the data access method based on the macvlan host network includes: creating a virtual logical vlan interface of at least one macvlan with a physical interface of a server as a parent interface; creating a macvlan sub-interface by taking the virtual logical vlan interface as a parent interface; creating at least one first virtual logical eth interface in at least one container of the server by taking the macvlan child interface as a parent interface, so that the first virtual logical eth interface is associated with a virtual network card in the container; receiving an access instruction of the virtual network card to access the macvlan sub-interface associated with the virtual network card; wherein, the macvlan sub-interface associated with the macvlan sub-interface is a father interface of a first virtual logical eth interface associated with the virtual network card; responding to the virtual network card based on the access instruction through a parent interface of a first virtual logical eth interface associated with the virtual network card.
The step of creating at least one first virtual logical eth interface in at least one container of the server by using the macvlan sub-interface as a parent interface, so that the first virtual logical eth interface is associated with a virtual network card in the container, includes: distributing the same network segment for the first virtual logical eth interface created by taking the same macvlan sub-interface as a father interface so as to establish an internal network; the data access method based on the macvlan host network further comprises the following steps: acquiring an access instruction of one of the first virtual logical eth interfaces to access other first virtual logical eth interfaces belonging to the same internal network; the access instruction is sent to a macvlan sub-interface corresponding to the internal network, the access instruction is sent to a corresponding first virtual logical eth interface through the macvlan sub-interface, and a response obtained based on the access instruction is returned to the first virtual logical eth interface for sending the access instruction through the macvlan sub-interface.
The data access method based on the macvlan host network further comprises the following steps: receiving an access request of a container corresponding to a first virtual logical eth interface of the other servers by the first virtual logical eth interface of the server through the macvlan sub-interface, and sending the access request to the physical interface through the virtual logical vlan interface; the server and the other servers are connected with the same switch and share one network segment; sending the access request to the switch through the physical interface, so as to forward the access request to the physical interface of the other server through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other server through the virtual logical vlan interface and the macvlan sub-interface of the other server, so as to access the container corresponding to the access request; receiving, by the physical interface, a response message returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response message is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response message to the switch through the virtual logical vlan interface and the physical interface of the other server; forwarding the response message to the physical interface of the server through the physical interface, and sequentially sending the response message to the first virtual logical eth interface of the server through the virtual logical vlan interface and the macvlan sub-interface of the server.
The data access method based on the macvlan host network further comprises the following steps: sending an access request of the server to a container corresponding to a first virtual logical eth interface of other servers through the physical interface to a switch, forwarding the access request to the physical interface of the other servers through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other servers through a virtual logical vlan interface and a macvlan sub-interface of the other servers to access the container corresponding to the first virtual logical eth interface of the other servers; the server and the other servers are connected with the same switch and share one network segment; receiving, by the physical interface, a response packet returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response packet is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response packet to the switch through the virtual logical vlan interface and the physical interface of the other server.
Wherein each virtual logical vlan interface has a different identity; establishing association between each virtual logical vlan interface and a trunk interface of a switch connected with the server through the identifier; the data access method based on the macvlan host network further comprises the following steps: receiving a message sent by a trunk interface of the switch through the physical interface; the message comprises an identifier of a virtual logic vlan interface; and sending the message to a virtual logic vlan interface corresponding to the identifier through the physical interface so as to distribute the message to a corresponding container through the interface.
The physical interfaces comprise a plurality of physical channels, wherein each channel corresponds to one virtual logic vlan interface and has the same identifier; the step of receiving the message sent by the trunk interface of the switch through the physical interface includes: identifying a trunk interface of a switch for transmitting the message based on the identification, and determining a physical channel for forwarding the message; receiving the message through the physical channel; the step of sending the message to the virtual logical vlan interface corresponding to the identifier through the physical interface so as to distribute the message to the corresponding container through the interface includes: and sending the message to a virtual logic vlan interface with the same identifier through the physical channel.
The data access method based on the macvlan host network further comprises the following steps: establishing at least one second virtual logical eth interface in the at least one container by taking the physical interface as a father interface; the same network segment is allocated to the at least one second virtual logical eth interface and the physical interface so as to establish a local area network of the server; receiving an instruction which is sent by one of the second virtual logical eth interfaces and accesses the corresponding container of the other second virtual logical eth interface through the physical interface; sending the instruction to the other accessed second virtual logical eth interface through the physical interface; and forwarding a response message, which is made by the container corresponding to the other second virtual logical eth interface based on the instruction, to the second virtual logical eth interface for sending the instruction.
The data access method based on the macvlan host network further comprises the following steps: receiving an access request of a container corresponding to a second virtual logical eth interface of the server to access a second virtual logical eth interface of other servers through the physical interface; the server and the other servers are connected with the same switch and share one network segment; sending the access request to the switch through the physical interface so as to forward the access request to the second virtual logical eth interface of the other server through the switch to access the corresponding container; receiving a response message returned by a container corresponding to the second virtual logical eth interface of the other server forwarded by the switch through the physical interface; forwarding the response message to the second virtual logical eth interface of the server through the physical interface
To solve the above problem, a second aspect of the present application provides a server based on a macvlan-hosting network, the server comprising: a physical interface; at least one virtual logical vlan interface, wherein the physical interface is a parent interface of the virtual logical vlan interface; at least one macvlan sub-interface, wherein the virtual logical vlan interface is a parent interface of the macvlan sub-interface; at least one container comprising a virtual network card and at least one first virtual logical eth interface, the first virtual logical eth interface establishing an association with the virtual network card in the container; the macvlan sub-interface is a father interface of a first virtual logical eth interface associated with the virtual network card, and is configured to receive an access instruction of the virtual network card to access the macvlan sub-interface, and respond to the virtual network card through the first virtual logical eth interface associated with the virtual network card based on the access instruction.
The container further comprises at least one second virtual logical eth interface, and the physical interface is a father interface of the second virtual logical eth interface; the physical interface is used for receiving an instruction which is sent by one of the second virtual logical eth interfaces and accesses a corresponding container of the other second virtual logical eth interface, and sending the instruction to the other accessed second virtual logical eth interface; and forwarding a response message, which is made by the container corresponding to the other second virtual logical eth interface based on the instruction, to the second virtual logical eth interface for sending the instruction.
To solve the above problem, a third aspect of the present application provides a system based on a macvlan-hosting network, where the system includes at least one switch and at least two servers, where two servers are connected to the same switch and share one network segment; the server is configured to execute the data access method based on the macvlan host network of the first aspect.
To solve the above-mentioned problem, a fourth aspect of the present application provides an electronic device, where the electronic device for locating the sound source azimuth includes a processor and a memory connected to each other; the memory is configured to store program instructions and the processor is configured to execute the program instructions to implement the data access method based on the macvlan host network of the first aspect.
To solve the above-mentioned problem, a fifth aspect of the present application provides a computer-readable storage medium having stored thereon program instructions that, when executed by a processor, implement the data access method based on the macvlan-host network of the first aspect.
The beneficial effects of the invention are as follows: different from the situation in the prior art, the method includes the steps that at least one virtual logic vlan interface of a macvlan is created by taking a physical interface of a server as a parent interface, a macvlan sub-interface is created by taking the virtual logic vlan interface as the parent interface, and at least one first virtual logic eth interface is created in at least one container of the server by taking the macvlan sub-interface as the parent interface, so that the first virtual logic eth interface is associated with a virtual network card in the container; then, an access instruction of the virtual network card to access the macvlan sub-interface associated with the virtual network card can be received, wherein the macvlan sub-interface associated with the virtual network card is a father interface of the first virtual logical eth interface associated with the virtual network card; and may respond to the virtual network card based on the access instruction through a parent interface of the first virtual logical eth interface associated with the virtual network card. By cascading the macvlan, a three-layer cascading macvlan host network is constructed, three-level cascading of the macvlan is realized from a physical interface of a server side to a first virtual logical eth interface of a container side, so that the first virtual logical eth interface of the container side and a macvlan sub-interface of the server side can be mutually accessed, and network intercommunication between the first virtual logical eth interface and a father interface in a bridging mode is realized.
Drawings
FIG. 1 is a flow chart of a first embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 2 is a flow chart of a second embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 3 is a flow chart of a third embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 4 is a flow chart of a fourth embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 5 is a flow chart of a fifth embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 6 is a flowchart of a sixth embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 7 is a flow chart of a seventh embodiment of a data access method based on a macvlan-hosting network according to the present application;
FIG. 8 is a schematic diagram illustrating the architecture of one embodiment of a server based on a macvlan hosting network in accordance with the present application;
FIG. 9 is a schematic diagram of another embodiment of a server based on a macvlan hosting network of the present application;
FIG. 10 is a schematic diagram of another embodiment of a system of the present application based on a macvlan-hosting network;
FIG. 11 is a schematic diagram of an embodiment of an electronic device of the present application;
FIG. 12 is a schematic diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The following describes the embodiments of the present application in detail with reference to the drawings.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, interfaces, techniques, etc., in order to provide a thorough understanding of the present application.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship. Further, "a plurality" herein means two or more than two.
Referring to fig. 1, fig. 1 is a flowchart of a first embodiment of a data access method based on a macvlan-host network according to the present application. The data access method based on the macvlan host network in the embodiment comprises the following steps:
step S11: a virtual logical vlan interface of at least one macvlan is created with the physical interface of the server as a parent interface.
Step S12: and creating a macvlan sub-interface by taking the virtual logical vlan interface as a parent interface.
Step S13: and creating at least one first virtual logical eth interface in at least one container of the server by taking the macvlan child interface as a parent interface so as to enable the first virtual logical eth interface to be associated with a virtual network card in the container.
Step S14: receiving an access instruction of the virtual network card to access the macvlan sub-interface associated with the virtual network card; the macvlan sub-interface associated with the macvlan sub-interface is a parent interface of the first virtual logical eth interface associated with the virtual network card.
Step S15: responding to the virtual network card based on the access instruction through a parent interface of a first virtual logical eth interface associated with the virtual network card.
It can be understood that, referring to fig. 8, fig. 8 is a schematic structural diagram of an embodiment of a server based on a macvlan host network in the present application, on the server 80 side, a virtual logical vlan interface 801 is created with a physical interface 800 as a parent interface, then a macvlan sub-interface 802 is created with the virtual logical vlan interface 801 as a parent interface, and then a first virtual logical eth interface 8030 on the container 803 side is created with the macvlan sub-interface 802 as a parent interface, thereby implementing a three-layer cascaded macvlan. By cascading the macvlan, a three-layer cascading macvlan host network is constructed, three-level cascading of the macvlan is realized from the physical interface 800 at the server 80 side to the first virtual logical eth interface 8030 at the container 803 side, so that the first virtual logical eth interface 8030 at the container 803 side and the macvlan sub-interface 802 at the server 80 side can access each other, and network intercommunication between the first virtual logical eth interface 8030 and the parent interface in the bridging mode is realized.
Referring to fig. 2, fig. 2 is a flowchart of a second embodiment of a data access method based on a macvlan-host network according to the present application. In an embodiment, the step S13 may specifically include: and distributing the same network segment for the first virtual logical eth interface created by the same macvlan sub-interface as a parent interface so as to establish an internal network. At this time, the data access method based on the macvlan-host network in the present embodiment may further include the steps of:
step S21: and acquiring an access instruction of one of the first virtual logical eth interfaces to access other first virtual logical eth interfaces belonging to the same internal network.
Step S22: and sending the access instruction to a macvlan sub-interface corresponding to the internal network, and sending the access instruction to a corresponding first virtual logical eth interface through the macvlan sub-interface.
Step S23: and returning a response obtained based on the access instruction to the first virtual logic eth interface for sending the access instruction through the macvlan sub-interface.
Specifically, referring to fig. 8, an internal network is established by allocating the same network segment to the first virtual logical eth interface 8030 created by using the same macvlan sub-interface 802 as a parent interface, so in the same server 80, a container 803 sends an access instruction to access other containers 803 belonging to the same internal network to the macvlan sub-interface 802 through the first virtual logical eth interface 8030, and then sends the access instruction to the first virtual logical eth interface 8030 corresponding to the other containers 803 through the macvlan sub-interface 802. That is, the containers 803 in the same server 80 may be mutually accessed through the first virtual logical eth interface 8030 by using the internal network, which also includes that the containers 803 access the macvlan sub-interface 802 corresponding thereto through the first virtual logical eth interface 8030.
Referring to fig. 3, fig. 3 is a flowchart of a third embodiment of a data access method based on a macvlan-host network according to the present application. The data access method based on the macvlan host network in this embodiment may further include the following steps:
step S31: receiving an access request of a container corresponding to a first virtual logical eth interface of the other servers by the first virtual logical eth interface of the server through the macvlan sub-interface, and sending the access request to the physical interface through the virtual logical vlan interface; the server and the other servers are connected with the same switch and share one network segment.
Step S32: and sending the access request to the switch through the physical interface, forwarding the access request to the physical interface of the other server through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other server through the virtual logical vlan interface and the macvlan sub-interface of the other server so as to access the corresponding container.
Step S33: receiving, by the physical interface, a response packet returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response packet is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response packet to the switch through the virtual logical vlan interface and the physical interface of the other server.
Step S34: forwarding the response message to the physical interface of the server through the physical interface, and sequentially sending the response message to the first virtual logical eth interface of the server through the virtual logical vlan interface and the macvlan sub-interface of the server.
Specifically, referring to fig. 10, fig. 10 is a schematic structural diagram of another embodiment of a system based on a macvlan-host network according to the present application, in the system 100 based on a macvlan-host network, including at least one switch 1000 and at least two servers 1001, if a container 803 of one server 1001 accesses a container 803 corresponding to a first virtual logical eth interface 8030 of another server 1001 through the first virtual logical eth interface 8030, the container 803 of the server 1001 sends an access request to the corresponding macvlan sub-interface 802 through the first virtual logical eth interface 8030, and the access request is sequentially sent to the switch 1000 through the corresponding virtual logical vlan interface 801 and the physical interface 800, and then sequentially passes through the physical interface 800, the virtual logical vlan interface 801 and the macvlan sub-interface 802 of the other server 1001, and then is sent to the first virtual logical eth interface 8030 of the other server 1001, so as to access the corresponding container 803. Then, the container 803 corresponding to the first virtual logical eth interface 8030 of the other server 1001 sends a response message to the corresponding macvlan sub-interface 802 through the first virtual logical eth interface 8030, the response message sequentially passes through the corresponding virtual logical vlan interface 801 and the physical interface 800, and is sent to the switch 1000, and then the response message sequentially passes through the physical interface 800, the virtual logical vlan interface 801 and the macvlan sub-interface 802 of the server 1001 through the switch 1000, and is sent to the first virtual logical eth interface 8030 of the server 1001.
Referring to fig. 4, fig. 4 is a flowchart of a fourth embodiment of a data access method based on a macvlan-host network according to the present application. The data access method based on the macvlan host network in this embodiment may further include the following steps:
step S41: sending an access request of the server to a container corresponding to a first virtual logical eth interface of other servers through the physical interface to the switch, forwarding the access request to the physical interface of the other servers through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other servers through a virtual logical vlan interface and a macvlan sub-interface of the other servers to access the container corresponding to the first virtual logical eth interface of the other servers; the server and the other servers are connected with the same switch and share one network segment.
Step S42: receiving, by the physical interface, a response packet returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response packet is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response packet to the switch through the virtual logical vlan interface and the physical interface of the other server.
Specifically, referring to fig. 10, in the system 100 based on the macvlan-hosting network, if a server 1001 accesses a container 803 corresponding to a first virtual logical eth interface 8030 of another server 1001, the server 1001 sends an access request to the switch 1000 through the physical interface 800, and then sends the access request to the first virtual logical eth interface 8030 of the other server 1001 through the switch 1000 sequentially through the physical interface 800, the virtual logical vlan interface 801 and the macvlan sub-interface 802 of the other server 1001 to access the container 803 corresponding thereto. Then, the container 803 corresponding to the first virtual logical eth interface 8030 of the other server 1001 sends a response message to the corresponding macvlan sub-interface 802 through the first virtual logical eth interface 8030, and the response message is sequentially sent to the switch 1000 through the corresponding virtual logical vlan interface 801 and the physical interface 800, and then sends the response message to the physical interface 800 of the server 1001 through the switch 1000.
Referring to fig. 5, fig. 5 is a flowchart of a fifth embodiment of a data access method based on a macvlan-host network according to the present application. Specifically, each virtual logical vlan interface has a different identification; and each virtual logic vlan interface establishes association with a trunk interface of a switch connected with the server through the identification. The data access method based on the macvlan host network in this embodiment may further include the following steps:
Step S51: receiving a message sent by a trunk interface of the switch through the physical interface; wherein the message includes an identification of the virtual logical vlan interface.
Step S52: and sending the message to a virtual logic vlan interface corresponding to the identifier through the physical interface so as to distribute the message to a corresponding container through the interface.
It can be understood that, referring to fig. 10, in order to adapt vlan partition of the switch 1000, the first virtual logical eth interface 8030 of the container 803 is a virtual logical vlan interface 801 because the parent interface of the two-layer mac vlan cascade is different identifiers of each virtual logical vlan interface 801, so that a packet sent by the virtual logical vlan interface 801 will be automatically marked with an identifier, and after the trunk interface of the switch 1000 sets the same identifier, a private network segment of the container network is implemented, so that, on one hand, ip address collision of the same private network segment on the switch 1000 is avoided, and on the other hand, isolation of the same private network segment on the switch 1000 is implemented.
Specifically, the physical interface 800 includes a plurality of physical channels (not shown), where each channel corresponds to one virtual logical vlan interface 801, and has the same identifier; therefore, the step S51 specifically includes: identifying a trunk interface of a switch for transmitting the message based on the identification, and determining a physical channel for forwarding the message; and receiving the message through the physical channel. The step S52 specifically includes: and sending the message to a virtual logic vlan interface with the same identifier through the physical channel. Therefore, after the switch 1000 receives the message, the message may be selected to be sent to the virtual logical vlan interface 801 with the same identifier through the physical channel corresponding to the identifier in the physical interface 800 according to the identifier carried by the message.
Referring to fig. 6, fig. 6 is a flowchart of a sixth embodiment of a data access method based on a macvlan-host network according to the present application. The data access method based on the macvlan host network in this embodiment may further include the following steps:
step S61: and establishing at least one second virtual logical eth interface in the at least one container by taking the physical interface as a father interface.
Step S62: and allocating the same network segment for the at least one second virtual logical eth interface and the physical interface to establish a local area network of the server.
Step S63: and receiving an instruction which is transmitted by one of the second virtual logical eth interfaces and accesses the corresponding container of the other second virtual logical eth interface through the physical interface.
Step S64: and sending the instruction to the accessed other second virtual logic eth interface through the physical interface.
Step S65: and forwarding a response message of the container corresponding to the other second virtual logical eth interface based on the instruction to the second virtual logical eth interface for sending the instruction.
Specifically, referring to fig. 9, fig. 9 is a schematic structural diagram of another embodiment of a server based on a macvlan host network in the present application, the server 80 side may further create a second virtual logical eth interface 8031 on the container 803 side with the physical interface 800 as a parent interface, and the second virtual logical eth interface 8031 on the container 803 side is a lan network segment, so that interconnection between the container network and the lan layer may be achieved. It can be understood that if two network cards of virtual logical eth interfaces are added to each container 803, that is, a first virtual logical eth interface 8030 and a second virtual logical eth interface 8031 are added at the same time, mutual access between the containers 803 and 803 can be performed through the second virtual logical eth interface 8031, and at this time, the traffic flows through the container network lan segment.
Referring to fig. 7, fig. 7 is a flowchart of a seventh embodiment of a data access method based on a macvlan-host network according to the present application. The data access method based on the macvlan host network in this embodiment may further include the following steps:
step S71: receiving an access request of a container corresponding to a second virtual logical eth interface of the server to access a second virtual logical eth interface of other servers through the physical interface; the server and the other servers are connected with the same switch and share one network segment.
Step S72: and sending the access request to the switch through the physical interface so as to forward the access request to the second virtual logical eth interface of the other server through the switch to access the corresponding container.
Step S73: and receiving response messages returned by the containers corresponding to the second virtual logical eth interfaces of the other servers forwarded by the switch through the physical interfaces.
Step S74: and forwarding the response message to the second virtual logical eth interface of the server through the physical interface.
Specifically, referring to fig. 10, in the system 100 based on the macvlan host network, if the container 803 of one server 1001 accesses the container 803 corresponding to the second virtual logical eth interface 8031 of the other server 1001 through the second virtual logical eth interface 8031, the container 803 of the server 1001 sends an access request through the second virtual logical eth interface 8031, the access request is sent to the switch 1000 through the corresponding physical interface 800, and then the access request is sent to the second virtual logical eth interface 8031 of the other server 1001 through the switch 1000 to access the container 803 corresponding thereto. Then, the container 803 corresponding to the second virtual logical eth interface 8031 of the other server 1001 sends the response message to the switch 1000 through the second virtual logical eth interface 8031, and then sends the response message to the physical interface 800 of the server 1001 through the switch 1000, and sends the response message to the second virtual logical eth interface 8031 of the container 803 of the server 1001 through the physical interface 800 of the server 1001. It can be understood that the server 1001 side uses the physical interface 800 as a parent interface to create the second virtual logical eth interface 8031 on the container 803 side, and the second virtual logical eth interface 8031 on the container 803 side joins the local area network where the physical interface 800 on the server 1001 side is located, so as to implement interconnection and interworking between the container 803 and the local area network layer of the server 1001.
The network topology presented in the embodiment of the present application may have two network planes, so as to implement flattening of the container network, the container internal network carries private traffic of the container network, and the container local network further implements interconnection with the local network where the server is located.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an embodiment of a server based on a macvlan-hosting network according to the present application. The macvlan-hosting network-based server 80 in this embodiment includes: a physical interface 800; at least one virtual logical vlan interface 801, wherein the physical interface 800 is a parent interface of the virtual logical vlan interface 801; at least one macvlan-sub-interface 802, the virtual logical vlan-interface 801 being a parent of the macvlan-sub-interface 802; at least one container 803, said container 803 comprising a virtual network card (not shown) and at least one first virtual logical eth interface 8030, said first virtual logical eth interface 8030 being associated with a virtual network card in said container 803; wherein the macvlan sub-interface 802 is a parent interface of the first virtual logical eth interface 8030 associated with the virtual network card, the macvlan sub-interface 802 is configured to receive an access instruction of the virtual network card to access the macvlan sub-interface 802, and respond to the virtual network card through the first virtual logical eth interface 8030 associated with the virtual network card based on the access instruction.
In one embodiment, as shown in connection with fig. 8, the container 803 further includes at least one second virtual logical eth interface 8031, and the physical interface 800 is a parent interface of the second virtual logical eth interface 8031.
Referring to FIG. 9, in one embodiment, each container 803 includes at least one second virtual logic eth interface 8031; the physical interface 800 is configured to receive an instruction sent by one of the second virtual logical eth interfaces 8031 to access a corresponding container 803 of the other of the second virtual logical eth interfaces 8031, and send the instruction to the other of the accessed second virtual logical eth interfaces 8031; and forwarding a response message of the container 803 corresponding to the other second virtual logical eth interface 8031 based on the instruction to the second virtual logical eth interface 8031 sending the instruction.
Referring to fig. 10, fig. 10 is a schematic structural diagram of another embodiment of a system based on a macvlan-host network according to the present application. The macvlan-hosting network-based system 100 in the present embodiment includes at least one switch 1000 and at least two servers 1001, and two servers 1001 are connected to the same switch 1000 and share one network segment; it will be appreciated that the switch 1000 is an access switch, and the server 1001 is configured to perform any of the foregoing data access methods based on the macvlan-hosting network. The server 1001 is the server 80 described above.
For details of the implementation of the data access method based on the macvlan-host network by the server 80 and the system 100 based on the macvlan-host network in the present application, please refer to the details in the foregoing embodiments of the data access method based on the macvlan-host network, which are not described herein again.
Referring to fig. 11, fig. 11 is a schematic structural diagram of an embodiment of an electronic device of the present application. The electronic device 110 in this embodiment includes a processor 1102 and a memory 1101 connected to each other; the memory 1101 is configured to store program instructions, and the processor 1102 is configured to execute the program instructions stored in the memory 1101 to implement the steps of any of the embodiments of the data access method based on a macvlan-host network described above. In one particular implementation scenario, electronic device 110 may include, but is not limited to: microcomputer, server.
In particular, the processor 1102 is configured to control itself and the memory 1101 to implement the steps of any of the macvlan-based host network data access method embodiments described above. The processor 1102 may also be referred to as a CPU (Central Processing Unit ). The processor 1102 may be an integrated circuit chip with signal processing capabilities. The processor 1102 may also be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a Field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 1102 may be commonly implemented by an integrated circuit chip.
Referring to fig. 12, fig. 12 is a schematic structural diagram of an embodiment of a computer readable storage medium of the present application. The computer readable storage medium 120 of the present application has program instructions 1200 stored thereon, which when executed by a processor, implement the steps in any of the embodiments of the data access method based on a macvlan-host network described above.
The computer readable storage medium 120 may be a medium such as a usb (universal serial bus), a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, which may store the program instructions 1200, or may be a server storing the program instructions 1200, and the server may send the stored program instructions 1200 to another device for execution, or may also self-execute the stored program instructions 1200.
In the several embodiments provided in the present application, it should be understood that the disclosed methods, servers, systems, devices, and apparatuses may be implemented in other manners. For example, the above-described apparatus and device embodiments are merely illustrative, e.g., the division of modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all or part of the technical solution contributing to the prior art or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.

Claims (13)

1. The data access method based on the macvlan host network is characterized by comprising the following steps of:
creating a virtual logical vlan interface of at least one macvlan with a physical interface of a server as a parent interface;
creating a macvlan sub-interface by taking the virtual logical vlan interface as a parent interface;
creating at least one first virtual logical eth interface in at least one container of the server by taking the macvlan child interface as a parent interface, so that the first virtual logical eth interface is associated with a virtual network card in the container;
the macvlan sub-interface receives an access instruction of the virtual network card to access the macvlan sub-interface associated with the virtual network card through the first virtual logical eth interface; wherein, the macvlan sub-interface associated with the macvlan sub-interface is a father interface of a first virtual logical eth interface associated with the virtual network card;
responding to the virtual network card based on the access instruction through a parent interface of a first virtual logical eth interface associated with the virtual network card.
2. The method of claim 1, wherein creating at least one first virtual logical eth interface in at least one container of the server with the macvlan child interface as a parent interface such that the first virtual logical eth interface is associated with a virtual network card in the container comprises:
Distributing the same network segment for the first virtual logical eth interface created by taking the same macvlan sub-interface as a father interface so as to establish an internal network;
the data access method based on the macvlan host network further comprises the following steps:
acquiring an access instruction of one of the first virtual logical eth interfaces to access other first virtual logical eth interfaces belonging to the same internal network;
transmitting the access instruction to a macvlan sub-interface corresponding to the internal network, transmitting the access instruction to a corresponding first virtual logical eth interface through the macvlan sub-interface, and
and returning a response obtained based on the access instruction to the first virtual logic eth interface for sending the access instruction through the macvlan sub-interface.
3. The macvlan-host-network-based data access method of claim 2, further comprising:
receiving an access request of a container corresponding to a first virtual logical eth interface of the other servers by the first virtual logical eth interface of the server through the macvlan sub-interface, and sending the access request to the physical interface through the virtual logical vlan interface; the server and the other servers are connected with the same switch and share one network segment;
Sending the access request to the switch through the physical interface, so as to forward the access request to the physical interface of the other server through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other server through the virtual logical vlan interface and the macvlan sub-interface of the other server, so as to access the container corresponding to the access request;
receiving, by the physical interface, a response message returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response message is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response message to the switch through the virtual logical vlan interface and the physical interface of the other server;
forwarding the response message to the physical interface of the server through the physical interface, and sequentially sending the response message to the first virtual logical eth interface of the server through the virtual logical vlan interface and the macvlan sub-interface of the server.
4. The macvlan-host-network-based data access method of claim 2, further comprising:
sending an access request of the server to a container corresponding to a first virtual logical eth interface of other servers through the physical interface to a switch, forwarding the access request to the physical interface of the other servers through the switch, and sequentially sending the access request to the first virtual logical eth interface of the other servers through a virtual logical vlan interface and a macvlan sub-interface of the other servers to access the container corresponding to the first virtual logical eth interface of the other servers; the server and the other servers are connected with the same switch and share one network segment;
receiving, by the physical interface, a response packet returned by a container corresponding to the first virtual logical eth interface of the other server forwarded by the switch, where the response packet is sent to the macvlan sub-interface of the other server through the first virtual logical eth interface of the other server, and sequentially sending the response packet to the switch through the virtual logical vlan interface and the physical interface of the other server.
5. The method for data access based on a macvlan-hosting network of claim 1, wherein each virtual logical vlan interface has a different identity; establishing association between each virtual logical vlan interface and a trunk interface of a switch connected with the server through the identifier; the data access method based on the macvlan host network further comprises the following steps:
receiving a message sent by a trunk interface of the switch through the physical interface; the message comprises an identifier of a virtual logic vlan interface;
and sending the message to a virtual logic vlan interface corresponding to the identifier through the physical interface so as to distribute the message to a corresponding container through the interface.
6. The method for accessing data based on a macvlan-hosting network as recited in claim 5, wherein the physical interface comprises a plurality of physical channels, wherein each channel corresponds to a virtual logical vlan interface and has the same identification;
the step of receiving the message sent by the trunk interface of the switch through the physical interface includes:
identifying a trunk interface of a switch for transmitting the message based on the identification, and determining a physical channel for forwarding the message;
Receiving the message through the physical channel;
the step of sending the message to the virtual logical vlan interface corresponding to the identifier through the physical interface so as to distribute the message to the corresponding container through the interface includes:
and sending the message to a virtual logic vlan interface with the same identifier through the physical channel.
7. The macvlan-host-network-based data access method of claim 1, further comprising:
establishing at least one second virtual logical eth interface in the at least one container by taking the physical interface as a father interface;
the same network segment is allocated to the at least one second virtual logical eth interface and the physical interface so as to establish a local area network of the server;
receiving an instruction which is sent by one of the second virtual logical eth interfaces and accesses the corresponding container of the other second virtual logical eth interface through the physical interface;
sending the instruction to the other accessed second virtual logical eth interface through the physical interface; and
and forwarding a response message of the container corresponding to the other second virtual logical eth interface based on the instruction to the second virtual logical eth interface for sending the instruction.
8. The macvlan-host-network-based data access method of claim 7, further comprising:
receiving an access request of a container corresponding to a second virtual logical eth interface of the server to access a second virtual logical eth interface of other servers through the physical interface; the server and the other servers are connected with the same switch and share one network segment;
sending the access request to the switch through the physical interface so as to forward the access request to the second virtual logical eth interface of the other server through the switch to access the corresponding container;
receiving a response message returned by a container corresponding to the second virtual logical eth interface of the other server forwarded by the switch through the physical interface;
and forwarding the response message to the second virtual logical eth interface of the server through the physical interface.
9. A server based on a macvlan hosting network, the server comprising:
a physical interface;
At least one virtual logical vlan interface, wherein the physical interface is a parent interface of the virtual logical vlan interface;
at least one macvlan sub-interface, wherein the virtual logical vlan interface is a parent interface of the macvlan sub-interface;
at least one container comprising a virtual network card and at least one first virtual logical eth interface, the first virtual logical eth interface establishing an association with the virtual network card in the container;
the macvlan sub-interface is a father interface of a first virtual logical eth interface associated with the virtual network card, and is configured to receive an access instruction of the virtual network card to access the macvlan sub-interface through the first virtual logical eth interface, and respond to the virtual network card through the first virtual logical eth interface associated with the virtual network card based on the access instruction.
10. The server according to claim 9, wherein the server is configured to,
the container further comprises at least one second virtual logical eth interface, and the physical interface is a father interface of the second virtual logical eth interface;
the physical interface is used for receiving an instruction which is sent by one of the second virtual logical eth interfaces and accesses a corresponding container of the other second virtual logical eth interface, and sending the instruction to the other accessed second virtual logical eth interface; and forwarding a response message, which is made by the container corresponding to the other second virtual logical eth interface based on the instruction, to the second virtual logical eth interface for sending the instruction.
11. A system based on a macvlan hosting network, characterized in that it comprises at least one exchange and at least two servers, both servers being connected to the same exchange and sharing a network segment; the server is configured to perform the macvlan-based data access method of any one of claims 1 to 8.
12. An electronic device comprising a processor and a memory connected to each other;
the memory is configured to store program instructions and the processor is configured to execute the program instructions to implement the macvlan-based data access method of any one of claims 1 to 8.
13. A computer readable storage medium having stored thereon program instructions, which when executed by a processor, implement the macvlan-host-network-based data access method of any one of claims 1 to 8.
CN202210088952.8A 2022-01-25 2022-01-25 Data access method, system and related device based on macvlan host network Active CN114629744B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210088952.8A CN114629744B (en) 2022-01-25 2022-01-25 Data access method, system and related device based on macvlan host network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210088952.8A CN114629744B (en) 2022-01-25 2022-01-25 Data access method, system and related device based on macvlan host network

Publications (2)

Publication Number Publication Date
CN114629744A CN114629744A (en) 2022-06-14
CN114629744B true CN114629744B (en) 2024-01-16

Family

ID=81898750

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210088952.8A Active CN114629744B (en) 2022-01-25 2022-01-25 Data access method, system and related device based on macvlan host network

Country Status (1)

Country Link
CN (1) CN114629744B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115189948B (en) * 2022-07-11 2023-05-12 北京志凌海纳科技有限公司 Method and system for realizing container network plug-in CaaS platform

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107566238A (en) * 2017-08-30 2018-01-09 成都安恒信息技术有限公司 A kind of method of User space configuration physical interface automatic identification vlan frames and non-vlan frames
CN110704155A (en) * 2018-07-09 2020-01-17 阿里巴巴集团控股有限公司 Container network construction method and device, physical host and data transmission method
EP3637684A1 (en) * 2018-10-12 2020-04-15 Siemens Aktiengesellschaft Method for automatically configuring a system, system, computer program and computer readable medium
CN111147450A (en) * 2019-12-09 2020-05-12 江苏艾佳家居用品有限公司 Container network isolation method based on macvlan mode
CN111404753A (en) * 2020-03-23 2020-07-10 星环信息科技(上海)有限公司 Flat network configuration method, computer equipment and storage medium
CN111885075A (en) * 2020-07-30 2020-11-03 广州华多网络科技有限公司 Container communication method, device, network equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9647894B2 (en) * 2014-07-30 2017-05-09 International Business Machines Corporation Mapping relationships among virtual elements across a system
US10868792B2 (en) * 2018-03-19 2020-12-15 Fortinet, Inc. Configuration of sub-interfaces to enable communication with external network devices

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107566238A (en) * 2017-08-30 2018-01-09 成都安恒信息技术有限公司 A kind of method of User space configuration physical interface automatic identification vlan frames and non-vlan frames
CN110704155A (en) * 2018-07-09 2020-01-17 阿里巴巴集团控股有限公司 Container network construction method and device, physical host and data transmission method
EP3637684A1 (en) * 2018-10-12 2020-04-15 Siemens Aktiengesellschaft Method for automatically configuring a system, system, computer program and computer readable medium
CN111147450A (en) * 2019-12-09 2020-05-12 江苏艾佳家居用品有限公司 Container network isolation method based on macvlan mode
CN111404753A (en) * 2020-03-23 2020-07-10 星环信息科技(上海)有限公司 Flat network configuration method, computer equipment and storage medium
CN111885075A (en) * 2020-07-30 2020-11-03 广州华多网络科技有限公司 Container communication method, device, network equipment and storage medium

Also Published As

Publication number Publication date
CN114629744A (en) 2022-06-14

Similar Documents

Publication Publication Date Title
US9698995B2 (en) Systems and methods for providing multicast routing in an overlay network
CN108965092B (en) Data message transmission method and device
EP3291089B1 (en) Data processing method and apparatus
CN111163130B (en) Network service system and data transmission method thereof
CN109617816B (en) Data message transmission method and device
CN111010329B (en) Message transmission method and device
CN112953774B (en) Network topology generation method, system, equipment and computer storage medium
US10193758B2 (en) Communication via a connection management message that uses an attribute having information on queue pair objects of a proxy node in a switchless network
CN110225146B (en) Intranet and extranet mapping method and device, electronic equipment, medium and video conference system
WO2018068588A1 (en) Method and software-defined networking (sdn) controller for providing multicast service
CN113535433A (en) Control forwarding separation method, device, equipment and storage medium based on Linux system
CN108696601A (en) Detect the hardware address conflict in computer network
CN110063045B (en) Message processing method and device in cloud computing system
CN109194589B (en) MDC (media data center) implementation method and device
CN114629744B (en) Data access method, system and related device based on macvlan host network
CN112583655B (en) Data transmission method and device, electronic equipment and readable storage medium
CN104426816A (en) Virtual machine communication method and device
US20180337827A1 (en) Method and Device for Reporting OpenFlow Switch Capability
CN110636149B (en) Remote access method, device, router and storage medium
CN114157633B (en) Message forwarding method and device
WO2017173989A1 (en) Method, device, and system for distribution processing on multicast and storage medium
CN114629844A (en) Message forwarding method and device and electronic equipment
CN114172853A (en) Flow forwarding and bare computer server configuration method and device
CN114050998A (en) Method, device, electronic equipment and medium for realizing remote direct memory access
CN113973101A (en) Method and device for processing table item information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant