CN115150327A - Interface setting method, device, equipment and medium - Google Patents

Interface setting method, device, equipment and medium Download PDF

Info

Publication number
CN115150327A
CN115150327A CN202210753285.0A CN202210753285A CN115150327A CN 115150327 A CN115150327 A CN 115150327A CN 202210753285 A CN202210753285 A CN 202210753285A CN 115150327 A CN115150327 A CN 115150327A
Authority
CN
China
Prior art keywords
virtual
interface
socket
bridge
network
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.)
Granted
Application number
CN202210753285.0A
Other languages
Chinese (zh)
Other versions
CN115150327B (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.)
Zhengzhou Inspur Data Technology Co Ltd
Original Assignee
Inspur Jinan data 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 Inspur Jinan data Technology Co ltd filed Critical Inspur Jinan data Technology Co ltd
Priority to CN202210753285.0A priority Critical patent/CN115150327B/en
Publication of CN115150327A publication Critical patent/CN115150327A/en
Application granted granted Critical
Publication of CN115150327B publication Critical patent/CN115150327B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/58Association of routers
    • H04L45/586Association of routers of virtual routers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/66Layer 2 routing, e.g. in Ethernet based MAN's
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses an interface setting method, an interface setting device, equipment and a medium, which relate to the technical field of computers and comprise the following steps: determining a data forwarding mode of a current network and determining the number of virtual machines of a current subnet; generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines; and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks. The method and the device generate a corresponding number of target sockets through the data forwarding mode of the current network card and the number of the virtual machines of the current subnet, and load the target sockets to the virtual bridge and the virtual router respectively so as to realize data communication of the virtual machines of each subnet. Therefore, by generating the target sockets with the number corresponding to the number of the virtual machines, network conflict caused by data forwarding through only one interface is avoided, and the performance and the efficiency of data forwarding are improved.

Description

Interface setting method, device, equipment and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for setting an interface.
Background
The forwarding of network data is mainly embodied in the encapsulation, processing and forwarding of data packets, and includes data of different ports, different data types and different network types. Currently, when data forwarding is performed, a Bridge Virtual Interface on a Virtual Bridge is in a BVI (Bridge Group Virtual Interface) Interface mode, that is, a BVI Interface is used to implement a data forwarding function between different ports. However, referring to fig. 1, the native routing interface, which is a set of bridge interfaces represented by one interface, has drawbacks and irrationality: that is, data in the same network segment is forwarded by one BVI interface, and when secondary forwarding is required, the same interface is defaulted, because the interface defaults that two gateways are in the same network segment, a router set in the same network can only pass through the same gateway, and network collision is easily caused.
In summary, how to improve data forwarding performance and avoid network collision is a problem to be solved at present.
Disclosure of Invention
In view of this, an object of the present invention is to provide an interface setting method, apparatus, device and medium, which can improve data forwarding performance and avoid network collision. The specific scheme is as follows:
in a first aspect, the present application discloses an interface setting method, including:
determining a data forwarding mode of a current network and determining the number of virtual machines of a current subnet;
generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines;
and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks.
Optionally, the determining the data forwarding mode of the current network includes:
if the data forwarding mode of the current network is determined to be two-layer forwarding;
correspondingly, the loading the target socket to the corresponding virtual bridge and the virtual router so that the virtual machines of the respective subnets perform data communication includes:
loading the target socket to a corresponding virtual bridge, so that each virtual machine of the current subnet can carry out data communication through the virtual bridge; wherein the number of the target sockets is the same as the number of the virtual machines.
Optionally, the determining the data forwarding mode of the current network includes:
if the data forwarding mode of the current network is determined to be three-layer forwarding;
correspondingly, the loading the target socket to the corresponding virtual bridge and the virtual router so that the virtual machines of the respective subnets perform data communication includes:
determining a plurality of set interface sets in the target socket; each socket group comprises a first set of interfaces and a second set of interfaces, and the number of the socket groups is the same as that of the virtual machines;
and loading the first set of interfaces in each socket group to a corresponding virtual bridge to serve as a server interface, and loading the second set of interfaces in each socket group to a corresponding virtual router to serve as a client interface, so that the virtual machines of the sub-networks perform data communication through the socket groups.
Optionally, the interface setting method further includes:
if the virtual machine interface in the current subnet changes, judging that the corresponding virtual router needs to execute interface adding operation or interface removing operation;
if interface adding operation needs to be executed, inquiring a subinterface corresponding to the current network, inserting the subinterface into a corresponding virtual bridge, and setting the subinterface in an enabled state;
and judging whether a socket corresponding to the current subnet exists, if not, creating a corresponding socket according to the data forwarding mode of the current network, and loading the socket to the corresponding virtual bridge and the subinterface of the virtual router.
Optionally, after the loading the socket to the corresponding virtual bridge and virtual router, the method further includes:
judging whether the current network is an external network or not;
if the network is an external network, starting a source address translation function, and setting an interface NAT in the virtual router to be in an external state.
Optionally, after determining that the corresponding virtual router needs to perform an interface addition operation or an interface removal operation, the method further includes:
if the interface removing operation needs to be executed, removing the corresponding socket from the virtual bridge and the virtual router, and judging whether other sockets exist in the virtual bridge and the virtual router;
and if not, removing the virtual bridge and the virtual router.
In a second aspect, the present application discloses an interface setting apparatus, comprising:
the information determining module is used for determining the data forwarding mode of the current network and determining the number of virtual machines of the current subnet;
a socket generating module, configured to generate a corresponding number of target sockets based on the data forwarding manner and the number of virtual machines;
and the socket loading module is used for loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the interface setting method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program realizes the steps of the interface setting method disclosed in the foregoing when being executed by a processor.
Therefore, the data forwarding mode of the current network is determined, and the number of the virtual machines of the current subnet is determined; generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines; and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks. Therefore, the data forwarding mode of the current network and the number of the virtual machines of the current subnet are determined, then the corresponding number of target sockets are generated according to the data forwarding mode of the current network card and the number of the virtual machines, and the generated target sockets are loaded to the virtual network bridge and the virtual router respectively, so that data communication among the virtual machines in each subnet is realized. Therefore, by generating the target sockets with the number corresponding to that of the virtual machines, network conflicts caused by data forwarding through only one interface are avoided, and the performance and the efficiency of data forwarding are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic diagram of a network interface for forwarding original data disclosed in the present application;
FIG. 2 is a flow chart of an interface setup method disclosed herein;
FIG. 3 is a flow chart of a specific interface setup method disclosed herein;
FIG. 4 is a schematic diagram of a specific network interface disclosed herein;
FIG. 5 is a flow chart of a specific interface setup method disclosed herein;
FIG. 6 is a flowchart of an interface setup method based on virtual machine interface changes as disclosed herein;
FIG. 7 is a schematic diagram of an interface setup based on virtual machine interface changes as disclosed herein;
FIG. 8 is a schematic structural diagram of an interface setting apparatus disclosed in the present application;
fig. 9 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
When data forwarding is currently performed, a Bridge Virtual Interface on a Virtual Bridge is in a BVI (Bridge Group Virtual Interface) Interface mode, that is, a BVI Interface is used to implement a data forwarding function between different ports. However, the native routing interface, which is a set of bridge interfaces represented by one interface, has drawbacks and irrationality: that is, data in the same network segment is forwarded by one BVI interface, and when secondary forwarding is required, the same interface is defaulted, because the interface defaults that two gateways are in the same network segment, a router set in the same network can only pass through the same gateway, and network collision is easily caused. Therefore, the embodiment of the application discloses an interface setting method, device, equipment and medium, which can improve the data forwarding performance and avoid network conflict.
Referring to fig. 2, an embodiment of the present application discloses an interface setting method, including:
step S11: and determining the data forwarding mode of the current network and determining the number of virtual machines of the current subnet.
In this embodiment, first, a data forwarding manner of a current network is determined, and the number of virtual machines of a current subnet is determined. It should be noted that the data forwarding manner may include two-layer forwarding and three-layer forwarding.
Step S12: and generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines.
In this embodiment, a corresponding number of target sockets are generated according to the data forwarding manner and the number of virtual machines, that is, data of the target sockets are determined according to the data forwarding manner and the number of virtual machines.
Step S13: and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks.
In this embodiment, after the target socket is generated, the target socket is loaded into the corresponding virtual bridge and the virtual router, so that the virtual machines of the subnets perform data communication, that is, the communication of the virtual machines is completed. The socket may be used for a virtual Host node user interface, and may provide services for a DHCP (Dynamic Host Configuration Protocol) terminal. Because the target sockets with the number corresponding to the number of the virtual machines are generated, network conflict caused by data forwarding through only one interface in the prior art is avoided, and faster and more efficient data forwarding is realized.
Therefore, the data forwarding mode of the current network is determined, and the number of the virtual machines of the current subnet is determined; generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines; and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks. Therefore, the data forwarding mode of the current network and the number of the virtual machines of the current subnet are determined, then the corresponding number of target sockets are generated according to the data forwarding mode of the current network card and the number of the virtual machines, and the generated target sockets are loaded to the virtual bridge and the virtual router respectively, so that data communication among the virtual machines in each subnet is realized. Therefore, by generating the target sockets with the number corresponding to that of the virtual machines, network conflicts caused by data forwarding through only one interface are avoided, and the performance and the efficiency of data forwarding are improved.
Referring to fig. 3, the embodiment of the present application discloses a specific interface setting method, and compared with the previous embodiment, the embodiment further describes and optimizes the technical solution. The method specifically comprises the following steps:
step S21: and if the data forwarding mode of the current network is determined to be two-layer forwarding, determining the number of the virtual machines of the current subnet.
In this embodiment, if the data forwarding manner of the current network is two-layer forwarding, the number of virtual machines of the current subnet is further determined.
Step S22: and generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines.
In this embodiment, a corresponding number of target sockets are generated by a data forwarding manner and the number of virtual machines. And for the two-layer forwarding, target sockets with the same number as the virtual machines are generated, and the target sockets correspond to the virtual machines one by one and can be distinguished through the set identification ID. It can be understood that when performing layer two forwarding, no route matching is needed, and therefore the interface does not need to configure MAC address and gateway IP, and the part of layer two forwarding can be completed only in the virtual bridge.
Step S23: loading the target socket to a corresponding virtual network bridge so that each virtual machine of the current sub-network can carry out data communication through the virtual network bridge; wherein the number of the target sockets is the same as the number of the virtual machines.
In this embodiment, since the two-layer forwarding does not need to perform route matching, and the data forwarding process can be completed through the virtual bridge, the target socket is only required to be loaded to the virtual bridge corresponding to the current subnet, so that each virtual machine of the current subnet performs data communication through the virtual bridge. It should be noted that the two-layer forwarding is applicable to two Virtual machines of the same network and the same host, and when the two Virtual machines communicate with each other, only the socket in the Virtual bridge is loaded to implement the two-layer forwarding, for example, in fig. 4, the data communication process between VM1 (Virtual Machine) and VM2 in the subnet 1 only needs to perform data communication through socket 0/1 and socket 0/2 of the bridge in fig. 4, and socket 0/1 corresponds to VM1 and socket 0/2 corresponds to VM 2.
It can be seen that, in the embodiment of the present application, if it is determined that the data forwarding manner of the current network is two-layer forwarding, the number of virtual machines in the current subnet is further determined, then target socket ports with the same number as the virtual machines are generated based on the two-layer forwarding manner of the data, and the target socket ports are loaded to the virtual bridge, so that each virtual machine in the current subnet realizes data communication. Because the generated target socket is corresponding to each virtual machine in the current subnet, different virtual machines adopt the corresponding sockets to forward data, network conflicts caused by that all virtual machines forward data only through the same interface are avoided, and meanwhile, the performance and the efficiency of data forwarding are improved.
Referring to fig. 5, the embodiment of the present application discloses a specific interface setting method, and compared with the previous embodiment, the embodiment further describes and optimizes the technical solution. The method specifically comprises the following steps:
step S31: and if the data forwarding mode of the current network is determined to be three-layer forwarding, determining the number of the virtual machines of the current subnet.
In this embodiment, if the data forwarding mode of the current network is three-layer forwarding, the number of virtual machines in the current subnet is further determined.
Step S32: and generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines.
In this embodiment, for three-layer forwarding, target sockets twice as many as the virtual machines are generated, and the target sockets and the virtual machines have a corresponding relationship and can also be distinguished by the set identifier ID. It can be understood that, when performing three-layer forwarding, the socket configures an MAC address and a gateway IP, and the opposite end connects with the socket of the virtual router to perform virtual routing forwarding, that is, three-layer forwarding, which relates to that the routing three-layer forwarding is completed in the virtual routing repeater.
Step S33: determining a plurality of set interface sets in the target socket; each socket group comprises a first set of interfaces and a second set of interfaces, and the number of the socket groups is the same as that of the virtual machines.
In this embodiment, it should be noted that there are several sets of interface groups in the target socket, each set of interface group includes a first set of interface and a second set of interface, and the number of the socket groups is the same as the number of the virtual machines. That is, if the forwarding is three-layer forwarding, a socket group corresponding to the virtual machine is generated.
Step S34: and loading the first set of interfaces in each socket group to a corresponding virtual bridge to serve as a server interface, and loading the second set of interfaces in each socket group to a corresponding virtual router to serve as a client interface, so that the virtual machines of the sub-networks perform data communication through the socket groups.
In this embodiment, a first set of interfaces in a socket group is loaded into a virtual bridge corresponding to a current subnet to serve as a server-side interface, a second set of interfaces in the socket group is loaded into a corresponding virtual router to serve as a client-side interface, when a user needs to point out, three-layer forwarding is applicable to two virtual machines of different networks and the same host, for a VLAN network, a VLAN tag needs to be changed on a virtual router of a network node, the three-layer forwarding passes through the virtual router, and a set of socket groups mapped to each other is loaded to match interfaces in a local-side bridge and the virtual router, thereby completing the three-layer forwarding. In this way, sockets can set multiple gateways for the same network segment, that is, one bridge can set multiple interfaces, and sockets appear in pairs. When a router is established to enable two virtual machines to communicate, the master-slave device mode sockets are complete, the network bridge at the virtual machine end serves as a service port and corresponds to a client port in a three-layer route forwarding process, a corresponding MAC address and a gateway IP are set, and forwarding can be carried out after a corresponding route forwarding action is inquired, so that the forwarding efficiency of the router is greatly improved. For data packets of types such as broadcast and unknown unicast, the data packets do not need to be flooded to all nodes so as to avoid the problems of overlarge load and the like, and the exclusive routing forwarding interface enables data forwarding to form a mesh shape so as not to cause network conflict.
In addition, the socket in this embodiment is a socket that can share the memory package, the shared memory package is set by using a file socket as a control channel, and thus the shared memory package can be used for communication, and the two ends of the socket are designed to be mapped to each other, in one-to-one correspondence, and serve as two roles similar to a server and a client, and the client is connected to the server through the existing socket. Each interface can be connected to a peer interface at the same time, distinguishable by a unique parameter identification ID and corresponding to the peer interface. For example, in fig. 4, data communication between VM1 or VM2 and VM3 is three-layer forwarding, and taking data communication between VM1 and VM3 as an example, socket 0/1 in the bridge corresponding to subnet 1, socket 0/1 in virtual router 1, socket 0/3 in virtual router 1 and socket 0/3 in the bridge corresponding to subnet 2 are needed to implement data communication between virtual machines VM1 and VM 3. Wherein, the socket 0/1 in the bridge corresponding to the subnet 1 and the socket 0/1 in the virtual router 1 are respectively used as a server interface and a client interface, and are in one-to-one correspondence, and similarly, the socket 0/3 in the bridge corresponding to the subnet 2 and the socket 0/3 in the virtual router 1 also have a correspondence.
Furthermore, for the same network and different hosts, the labels carried by the different hosts cannot be intercommunicated when the different hosts are communicated with each other, and the labels in the network packet can be converted through the socket of the application to match the two layers of intercommunication; when external network communication is connected, floating IP or fixed IP network communication is added, and the external network connection is still provided by the network bridge, so that communication of a plurality of network components is not needed, namely, only a group of mapping sockets provided by the application are needed to be connected with the internal network bridge, and the virtual router is connected with the external network for forwarding.
It can be seen that, in the embodiment of the present application, if it is determined that the data forwarding manner of the current network is three-tier forwarding, the number of virtual machines of the current subnet is further determined, then a complete set of socket groups is generated based on the three-tier forwarding manner of the data to serve as a client interface and a server interface, respectively, and the server interface is loaded to the virtual bridge and the client interface is loaded to the virtual router. The virtual router data plane forwarding function is realized by the socket in pair aiming at the network data forwarding interface, the receiving and sending processes of the network communication implementation mode to the data packet are optimized, the forwarding efficiency of the data forwarding plane to the data processing process is improved, the data packet processing process is improved so as to realize three-layer routing forwarding better, and the virtual router data plane forwarding function has different gateway functions when a plurality of routers are bound to the same network. By the method, network conflict can be avoided, the forwarding performance of the network data packet can be improved, the length of a network data link is shortened, and delay of the network is avoided. And particularly, when the network forwarding is carried out in a large flow and the throughput is high, the network data forwarding is faster and more efficient.
In the data processing process, different network ports of each network segment may load independent interfaces and set a fault tolerance mechanism, as shown in fig. 6 and 7, an embodiment of the present application discloses a network interface setting method suitable for interface change of a virtual machine, including:
step S41: and if the virtual machine interface in the current subnet changes, judging that the corresponding virtual router needs to execute interface adding operation or interface removing operation.
In this embodiment, if the virtual machine interface of the current subnet changes, it is determined that the corresponding virtual router needs to perform an interface adding operation or an interface removing operation, and then corresponding configuration is performed according to the action.
Step S42: and if interface adding operation needs to be executed, inquiring a subinterface corresponding to the current network, inserting the subinterface into a corresponding virtual network bridge, and setting the subinterface in an enabling state.
In this embodiment, if the operation is an interface addition operation, a subinterface corresponding to the current network is queried, the subinterface is inserted into the corresponding virtual network bridge, and the state of the network subinterface is set to be an enabled state; if the subinterface corresponding to the current network does not exist when the subinterface is inquired, the subinterface needs to be created first. When it is necessary to pay attention to, before inquiring the sub-interfaces, it is necessary to determine whether the network card that depends on exists and is normal, if there is no direct return error, if there is and the network card is normal in the enabled state, the sub-interface corresponding to the network is inquired.
In another specific embodiment, after the determining that the corresponding virtual router needs to perform the interface adding operation or the interface removing operation, the method further includes: if the interface removing operation needs to be executed, removing the corresponding socket from the virtual bridge and the virtual router, and judging whether other sockets exist in the virtual bridge and the virtual router; if not, removing the virtual bridge and the virtual router. That is, if the interface removal operation is performed, the corresponding socket is directly removed from the virtual bridge and the virtual router, and it is determined whether there is a socket providing another routing function in the virtual bridge and the virtual router, and if not, the virtual bridge and the virtual router are also removed together. Further, after determining whether there are other sockets in the virtual bridge and the virtual router, the method further includes: if other sockets exist in the virtual router, reserving the virtual router; and if other sockets exist in the virtual bridge, reserving the virtual bridge. That is, if the interface is an interface removing operation, it is also necessary to determine whether an interface corresponding to the current subnet interface exists, if not, an error is returned, if so, an interface in a two-layer bridge process and an interface in a three-layer route forwarding process are deleted, and then, it is determined whether a virtual router in which the interface in the three-layer virtual routing process is located has another interface providing a routing function, if not, the virtual router is deleted, and it is determined whether another interface exists in the two-layer bridge, if not, the bridge is directly removed, and if there is another interface, the bridge needs to be retained.
Step S43: and judging whether a socket corresponding to the current subnet exists, if not, creating a corresponding socket according to the data forwarding mode of the current network, and loading the socket to the corresponding virtual bridge and the subinterface of the virtual router.
In this embodiment, it needs to determine whether there is a socket corresponding to the current subnet, and if not, create a corresponding socket according to the data forwarding manner of the current network, and load the socket into the subinterfaces of the virtual bridge and the virtual router. For example, if the forwarding is three-layer forwarding, a server interface is created in the second-layer bridge, a client interface is created in the virtual router for three-layer forwarding, the issued MAC is set as the corresponding client interface, then the corresponding virtual router is inserted and the interface state is set to be enabled, if the virtual router does not exist, the gateway IP is set for the three-layer virtual router forwarding interface according to the issued configuration. It should be noted that if the Source Address Translation (SNAT) function is already turned on, the same Network in the fixed virtual router may only need to share one socket.
In addition, after the loading the socket to the corresponding virtual bridge and the virtual router, the method further includes: judging whether the current network is an external network or not; if the network is an external network, starting a source address translation function, and setting an interface NAT in the virtual router to be in an external state. It can be understood that the present embodiment needs to determine whether the current network is an external network or an internal network. If the virtual router is an external network, a source address conversion function needs to be started, an interface NAT in the virtual router is set to be in an external state, and a gateway IP is set to be a dynamic NAT address based on the current virtual router; if the network is an internal network, the interface gateway in the three-layer virtual route forwarding process is directly set to be in an internal state. It should be noted that, if the external network is used, it is necessary to determine whether to start the source address translation function, and if not, subsequent related configuration is not required.
It can be seen that if the virtual machine interface in the current subnet changes, the interface adding operation and the interface removing operation need to be executed according to the specific change. If the operation is the interface adding operation, firstly judging whether the network card is normal or not, further inquiring whether a sub-interface corresponding to the current network exists or not, if so, inserting the sub-interface into the virtual network bridge and setting the sub-interface to be in a starting state, then judging whether a socket interface corresponding to the current subnet exists or not, and if not, establishing a socket interface group and respectively loading the socket interface group to the virtual network bridge and the virtual router so as to finish the interface adding operation. If the interface removing operation is performed, firstly, corresponding sockets are directly removed from the virtual bridge and the virtual router, then whether other interfaces provide routing functions or not is determined, if not, the virtual bridge and the virtual router are also removed, and if the virtual bridge or the virtual router also has other sockets providing routing functions, the virtual bridge or the virtual router is reserved.
Referring to fig. 8, an embodiment of the present application discloses an interface setting apparatus, including:
an information determining module 11, configured to determine a data forwarding manner of a current network, and determine the number of virtual machines in a current subnet;
a socket generating module 12, configured to generate a corresponding number of target sockets based on the data forwarding manner and the number of virtual machines;
and a socket loading module 13, configured to load the target socket to a corresponding virtual bridge and a corresponding virtual router, so that the virtual machines of the subnets perform data communication.
Therefore, the data forwarding mode of the current network is determined, and the number of the virtual machines of the current subnet is determined; generating a corresponding number of target sockets based on the data forwarding mode and the number of the virtual machines; and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks. Therefore, the data forwarding mode of the current network and the number of the virtual machines of the current subnet are determined, then the corresponding number of target sockets are generated according to the data forwarding mode of the current network card and the number of the virtual machines, and the generated target sockets are loaded to the virtual network bridge and the virtual router respectively, so that data communication among the virtual machines in each subnet is realized. Therefore, by generating the target sockets with the number corresponding to the number of the virtual machines, network conflict caused by data forwarding through only one interface is avoided, and the performance and the efficiency of data forwarding are improved.
In some specific embodiments, the information determining module 11 may specifically include:
a first determining unit, configured to determine that a data forwarding manner of a current network is two-layer forwarding;
correspondingly, the socket loading module 13 may specifically include:
the first loading unit is used for loading the target socket to a corresponding virtual bridge so as to facilitate each virtual machine of the current subnet to carry out data communication through the virtual bridge; wherein the number of the target sockets is the same as the number of the virtual machines.
In some specific embodiments, the information determining module 11 may specifically include:
a second determining unit, configured to determine that a data forwarding manner of the current network is three-layer forwarding;
correspondingly, the socket loading module 13 may specifically include:
a socket group determining unit, configured to determine a plurality of socket group interface groups in the target socket; each socket group comprises a first set of interfaces and a second set of interfaces, and the number of the socket groups is the same as that of the virtual machines;
a second loading unit, configured to load the first set of interfaces in each socket group to a corresponding virtual bridge to serve as a server interface, and load the second set of interfaces in each socket group to a corresponding virtual router to serve as a client interface, so that the virtual machines of the respective subnets perform data communication through the socket groups.
In some specific embodiments, the interface setting device may further include:
the operation judging unit is used for judging that the corresponding virtual router needs to execute interface adding operation or interface removing operation if the virtual machine interface in the current subnet changes;
a subinterface setting unit, configured to query a subinterface corresponding to the current network if an interface addition operation needs to be performed, insert the subinterface into a corresponding virtual bridge, and set the subinterface in an enabled state;
and the socket creating unit is used for judging whether a socket corresponding to the current subnet exists or not, if not, creating a corresponding socket according to the data forwarding mode of the current network, and loading the socket to the corresponding virtual bridge and the subinterface of the virtual router.
In some specific embodiments, after the socket creating unit, the method may further include:
a network judging unit, configured to judge whether the current network is an external network;
and the source address conversion unit is used for starting a source address conversion function if the network is an external network, and setting an interface NAT in the virtual router to be in an external state.
In some specific embodiments, after the operating the determining unit, the operating may further include:
a socket removing unit, configured to remove a corresponding socket from the virtual bridge and the virtual router if an interface removing operation needs to be performed, and determine whether other sockets exist in the virtual bridge and the virtual router;
a router removal unit, configured to remove the virtual bridge and the virtual router if the virtual bridge and the virtual router do not exist.
In some specific embodiments, after the socket removing unit, the method may further include:
a reservation unit, configured to reserve the virtual router if there are other sockets in the virtual router; and if other sockets exist in the virtual bridge, reserving the virtual bridge.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The method specifically comprises the following steps: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the interface setting method executed by the electronic device disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to acquire external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
In addition, the storage 22 is used as a carrier for storing resources, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., the resources stored thereon include an operating system 221, a computer program 222, data 223, etc., and the storage may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device on the electronic device 20 and the computer program 222, so as to implement the operation and processing of the mass data 223 in the memory 22 by the processor 21, which may be Windows, unix, linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the interface setting method performed by the electronic device 20 disclosed in any of the foregoing embodiments. The data 223 may include data received by the electronic device and transmitted from an external device, or may include data collected by the input/output interface 25 itself.
Further, an embodiment of the present application also discloses a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is loaded and executed by a processor, the method steps executed in the interface setting process disclosed in any of the foregoing embodiments are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the components and steps of the various examples have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The above detailed description is provided for an interface setting method, apparatus, device and storage medium provided by the present invention, and a specific example is applied in the present text to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. An interface setting method, comprising:
determining a data forwarding mode of a current network and determining the number of virtual machines of a current subnet;
generating a corresponding number of target sockets based on the data forwarding mode and the number of virtual machines;
and loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks.
2. The interface setting method according to claim 1, wherein the determining a data forwarding manner of the current network includes:
if the data forwarding mode of the current network is determined to be two-layer forwarding;
correspondingly, the loading the target socket to the corresponding virtual bridge and virtual router so that the virtual machines of the respective subnets perform data communication includes:
loading the target socket to a corresponding virtual network bridge so that each virtual machine of the current sub-network can carry out data communication through the virtual network bridge; wherein the number of the target sockets is the same as the number of the virtual machines.
3. The interface setting method according to claim 1, wherein the determining a data forwarding manner of the current network includes:
if the data forwarding mode of the current network is determined to be three-layer forwarding;
correspondingly, the loading the target socket to the corresponding virtual bridge and the virtual router so that the virtual machines of the respective subnets perform data communication includes:
determining a plurality of set interface sets in the target socket; each socket group comprises a first set of interfaces and a second set of interfaces, and the number of the socket groups is the same as that of the virtual machines;
and loading the first set of interfaces in each socket group to a corresponding virtual bridge to serve as a server interface, and loading the second set of interfaces in each socket group to a corresponding virtual router to serve as a client interface, so that the virtual machines of the sub-networks perform data communication through the socket groups.
4. The interface setting method according to any one of claims 1 to 3, characterized by further comprising:
if the virtual machine interface in the current subnet changes, judging that the corresponding virtual router needs to execute interface adding operation or interface removing operation;
if interface adding operation needs to be executed, inquiring a subinterface corresponding to the current network, inserting the subinterface into a corresponding virtual bridge, and setting the subinterface in an enabled state;
and judging whether a socket corresponding to the current subnet exists, if not, creating a corresponding socket according to the data forwarding mode of the current network, and loading the socket to the corresponding virtual bridge and the subinterface of the virtual router.
5. The interface setting method according to claim 4, wherein after loading the socket to the corresponding virtual bridge and virtual router, the method further comprises:
judging whether the current network is an external network or not;
if the network is an external network, starting a source address translation function, and setting an interface NAT in the virtual router to be in an external state.
6. The interface setting method according to claim 4, wherein after determining that the corresponding virtual router needs to perform the interface adding operation or the interface removing operation, the method further comprises:
if the interface removing operation needs to be executed, removing the corresponding socket from the virtual bridge and the virtual router, and judging whether other sockets exist in the virtual bridge and the virtual router;
and if not, removing the virtual bridge and the virtual router.
7. The interface setting method according to claim 6, wherein after determining whether there are other sockets in the virtual bridge and the virtual router, the method further comprises:
if other sockets exist in the virtual router, reserving the virtual router; and if other sockets exist in the virtual bridge, reserving the virtual bridge.
8. An interface setting apparatus, comprising:
the information determining module is used for determining the data forwarding mode of the current network and determining the number of virtual machines of the current subnet;
a socket generating module, configured to generate a corresponding number of target sockets based on the data forwarding manner and the number of virtual machines;
and the socket loading module is used for loading the target socket to the corresponding virtual bridge and the virtual router so as to facilitate the data communication of the virtual machines of the sub-networks.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to carry out the steps of the interface setting method according to any of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program realizes the steps of the interface setting method according to any one of claims 1 to 7 when executed by a processor.
CN202210753285.0A 2022-06-29 2022-06-29 Interface setting method, device, equipment and medium Active CN115150327B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210753285.0A CN115150327B (en) 2022-06-29 2022-06-29 Interface setting method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210753285.0A CN115150327B (en) 2022-06-29 2022-06-29 Interface setting method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN115150327A true CN115150327A (en) 2022-10-04
CN115150327B CN115150327B (en) 2024-06-14

Family

ID=83410487

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210753285.0A Active CN115150327B (en) 2022-06-29 2022-06-29 Interface setting method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115150327B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016320A (en) * 2022-12-30 2023-04-25 中国联合网络通信集团有限公司 Data transmission method, device and computer readable storage medium
CN116436787A (en) * 2023-06-13 2023-07-14 苏州浪潮智能科技有限公司 Network interface management method, use method, device, equipment and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683165A (en) * 2013-11-27 2015-06-03 北京天地超云科技有限公司 Monitor method for virtual machine network data in Xen virtual environment
WO2017032300A1 (en) * 2015-08-25 2017-03-02 华为技术有限公司 Data transmission method, virtual network management apparatus, and data transmission system
CN106487695A (en) * 2015-08-25 2017-03-08 华为技术有限公司 A kind of data transmission method, virtual network managing device and data transmission system
CN108337186A (en) * 2017-01-20 2018-07-27 谷歌有限责任公司 Device and method for scalable traffic shaping
CN109413052A (en) * 2018-10-09 2019-03-01 郑州云海信息技术有限公司 Virtual machine communication system and virtual machine
CN109547349A (en) * 2018-12-06 2019-03-29 郑州云海信息技术有限公司 Flow managing method, device, terminal and storage medium based on virtual flow-line
CN109714238A (en) * 2018-12-11 2019-05-03 上海云轴信息科技有限公司 A kind of method and apparatus for realizing inter-virtual machine communication
CN109743205A (en) * 2018-12-29 2019-05-10 浪潮电子信息产业股份有限公司 A kind of cloud platform OS network management, device and server
US20190273718A1 (en) * 2018-03-01 2019-09-05 ShieldX Networks, Inc. Intercepting network traffic routed by virtual switches for selective security processing
CN111078359A (en) * 2019-12-10 2020-04-28 上海英方软件股份有限公司 Method and system for realizing virtual machine instant recovery through directory mapping
CN112217746A (en) * 2016-11-09 2021-01-12 华为技术有限公司 Method, host and system for processing message in cloud computing system
CN112702252A (en) * 2019-10-23 2021-04-23 华为技术有限公司 Message processing method, system and related equipment

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683165A (en) * 2013-11-27 2015-06-03 北京天地超云科技有限公司 Monitor method for virtual machine network data in Xen virtual environment
WO2017032300A1 (en) * 2015-08-25 2017-03-02 华为技术有限公司 Data transmission method, virtual network management apparatus, and data transmission system
CN106487695A (en) * 2015-08-25 2017-03-08 华为技术有限公司 A kind of data transmission method, virtual network managing device and data transmission system
CN112217746A (en) * 2016-11-09 2021-01-12 华为技术有限公司 Method, host and system for processing message in cloud computing system
CN108337186A (en) * 2017-01-20 2018-07-27 谷歌有限责任公司 Device and method for scalable traffic shaping
US20190273718A1 (en) * 2018-03-01 2019-09-05 ShieldX Networks, Inc. Intercepting network traffic routed by virtual switches for selective security processing
CN109413052A (en) * 2018-10-09 2019-03-01 郑州云海信息技术有限公司 Virtual machine communication system and virtual machine
CN109547349A (en) * 2018-12-06 2019-03-29 郑州云海信息技术有限公司 Flow managing method, device, terminal and storage medium based on virtual flow-line
CN109714238A (en) * 2018-12-11 2019-05-03 上海云轴信息科技有限公司 A kind of method and apparatus for realizing inter-virtual machine communication
CN109743205A (en) * 2018-12-29 2019-05-10 浪潮电子信息产业股份有限公司 A kind of cloud platform OS network management, device and server
CN112702252A (en) * 2019-10-23 2021-04-23 华为技术有限公司 Message processing method, system and related equipment
CN111078359A (en) * 2019-12-10 2020-04-28 上海英方软件股份有限公司 Method and system for realizing virtual machine instant recovery through directory mapping

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
XIN GUO; PENG YANG; XI CHEN; ZHIQIANG LIU; XUELING SONG: "The implementation of virtual machining of the prosthetic socket based on OpenGL", PROCEEDINGS OF THE 4TH WORLD CONGRESS ON INTELLIGENT CONTROL AND AUTOMATION (CAT. NO.02EX527) *
周德江;: "基于Serval的广域网下虚拟机在线迁移系统", 电子世界, no. 01 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016320A (en) * 2022-12-30 2023-04-25 中国联合网络通信集团有限公司 Data transmission method, device and computer readable storage medium
CN116016320B (en) * 2022-12-30 2024-03-19 中国联合网络通信集团有限公司 Data transmission method, device and computer readable storage medium
CN116436787A (en) * 2023-06-13 2023-07-14 苏州浪潮智能科技有限公司 Network interface management method, use method, device, equipment and storage medium
CN116436787B (en) * 2023-06-13 2023-08-15 苏州浪潮智能科技有限公司 Network interface management method, use method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN115150327B (en) 2024-06-14

Similar Documents

Publication Publication Date Title
US20200028758A1 (en) Multi-cloud connectivity using srv6 and bgp
US11394607B2 (en) Method and system for network configuration
CN115150327B (en) Interface setting method, device, equipment and medium
CN109728962B (en) Method and equipment for sending message
CN108429680B (en) Route configuration method, system, medium and equipment based on virtual private cloud
US11310080B2 (en) VXLAN configuration method, device, and system
US10574570B2 (en) Communication processing method and apparatus
US20140376402A1 (en) Methods and systems for automatic generation of routing configuration files
EP4220427A1 (en) Data processing method and system, encapsulation node, and de-encapsulation node
CN111556110B (en) Automatic adaptation method for different physical service networks of private cloud system
CN115189920A (en) Cross-network domain communication method and related device
CN114465776A (en) Flooding attack defense method and related device
US11929851B2 (en) Gateway selection method, device, and system
CN114866467A (en) Cluster communication method, device, system, equipment and readable storage medium
CN114650290B (en) Network communication method, processing device, terminal and storage medium
CN111464443B (en) Message forwarding method, device, equipment and storage medium based on service function chain
CN108512737B (en) Data center IP layer interconnection method and SDN controller
CN115550377A (en) NVMF (network video and frequency) storage cluster node interconnection method, device, equipment and medium
CN117097818A (en) Message processing method and related equipment
CN113542441B (en) Communication processing method and device
CN110545240B (en) Method for establishing label forwarding table and forwarding message based on distributed aggregation system
CN115941455A (en) Method and communication device for intercommunication between cloud network and operator network of data center
CN108259292B (en) Method and device for establishing tunnel
CN115334036B (en) Method and device for intelligently controlling source address conversion, electronic equipment and storage medium
EP4395247A1 (en) Method and apparatus for receiving border gateway protocol routing, method and apparatus for sending border gateway protocol routing, and storage medium

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20240425

Address after: Room 1801, 18th Floor, Jiyun Investment Building, No. 278 Xinyi Road, Zhengdong New District, Zhengzhou City, Henan Province, 450047

Applicant after: Zhengzhou Inspur Data Technology Co.,Ltd.

Country or region after: China

Address before: 250101 room s311, building S05, Inspur Science Park, No. 1036, Inspur Road, Jinan pilot Free Trade Zone, Jinan, Shandong Province

Applicant before: Inspur(Jinan)Data Technology Co.,Ltd

Country or region before: China

GR01 Patent grant
GR01 Patent grant