Disclosure of Invention
In view of this, embodiments of the present invention provide a method, a device, and a medium for configuring a virtual local area network of a white box switch, which can prevent the switch from having conditions such as a wrong VLAN name, a wrong mask address, and the like by checking a VLAN ID, an IP address, and a mask, and ensure normal operation of a switch service.
Based on the above object, an aspect of the embodiments of the present invention provides a method for configuring a virtual local area network of a white box switch, including the following steps: inquiring the configured virtual local area network ID of the white box switch, and forming a VLAN ID table; in response to receiving a command for configuring a virtual local area network, creating a new virtual local area network ID, and judging whether the new virtual local area network ID exists in the VLAN ID table or not; responding to the situation that the new virtual local area network ID does not exist in the VLAN ID table, setting the IP address of the new virtual local area network ID, and judging whether the IP address and the IP address which already exists in the VLAN ID table belong to the same network segment; and responding to the fact that the IP address and the existing IP address in the VLAN ID table do not belong to the same network segment, and configuring a mask of the IP address.
In some embodiments, said configuring the mask of the IP address comprises: judging whether mask setting exists in the command or not; and in response to the mask setting being present in the command, determining whether the mask setting is a correct number of bits and performing the setting based on the determination.
In some embodiments, further comprising: in response to receiving a command to delete an IP address corresponding to an ID, the corresponding IP address is deleted from the vlan ID table.
In some embodiments, said removing said corresponding IP address from the VLAN ID table comprises: judging whether the ID corresponding to the ID exists in the VLANID table or not; and in response to the presence of the ID corresponding to the ID in the vlan ID table, determining whether the corresponding IP address is present and performing deletion based on the determination result.
In some embodiments, the determining whether the corresponding IP address exists comprises: and judging whether the corresponding IP address has a mask or not.
In another aspect of the embodiments of the present invention, there is also provided a computer device, including: at least one processor; and a memory storing computer instructions executable on the processor, the instructions being executable by the processor to perform the steps of: inquiring the configured virtual local area network ID of the white box switch, and forming a VLAN ID table; in response to receiving a command for configuring a virtual local area network, creating a new virtual local area network ID, and judging whether the new virtual local area network ID exists in the VLAN ID table or not; responding to the situation that the new virtual local area network ID does not exist in the VLAN ID table, setting the IP address of the new virtual local area network ID, and judging whether the IP address and the IP address which already exists in the VLAN ID table belong to the same network segment; and responding to the fact that the IP address and the existing IP address in the VLAN ID table do not belong to the same network segment, and configuring a mask of the IP address.
In some embodiments, said configuring the mask of the IP address comprises: judging whether mask setting exists in the command or not; and in response to the mask setting being present in the command, determining whether the mask setting is a correct number of bits and performing the setting based on the determination.
In some embodiments, the steps further comprise: in response to receiving a command to delete an IP address corresponding to an ID, the corresponding IP address is deleted from the VLAN ID table.
In some embodiments, said removing said corresponding IP address from the VLAN ID table comprises: judging whether the ID corresponding to the ID exists in the VLANID table or not; and in response to the presence of the ID corresponding to the ID in the vlan ID table, determining whether the corresponding IP address is present and performing deletion based on the determination result.
In a further aspect of the embodiments of the present invention, a computer-readable storage medium is also provided, in which a computer program for implementing the above method steps is stored when the computer program is executed by a processor.
The invention has the following beneficial technical effects: by checking the VLAN ID, the IP address and the mask code, the conditions of wrong VLAN names, wrong mask code addresses and the like of the switch can be prevented, and the normal operation of the switch service is ensured.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
In view of the above-mentioned objects, a first aspect of the embodiments of the present invention provides an embodiment of a method for configuring a virtual local area network of a white box switch. Fig. 1 is a schematic diagram illustrating an embodiment of a method for configuring a virtual local area network of a white box switch according to the present invention. As shown in fig. 1, the embodiment of the present invention includes the following steps:
s1, inquiring the configured virtual local area network ID of the white box switch, and forming a VLAN (virtual local area network) ID table;
s2, responding to the command of receiving the configuration virtual local area network, creating a new virtual local area network ID, and judging whether the new virtual local area network ID exists in the VLANID table;
s3, responding to the VLAN ID table without the new virtual local area network ID, setting the IP address of the new virtual local area network ID, and judging whether the IP address and the existing IP address in the VLAN ID table belong to the same network segment; and
and S4, configuring the mask of the IP address in response to the fact that the IP address and the IP address already existing in the VLAN ID table do not belong to the same network segment.
The white box switch is a switch with thoroughly separated hardware and software, and when the hardware switch leaves a factory, except BootLoader (software), no software exists, and a customer can additionally purchase software or write software according to own requirements. The existing white box switch added and deleted VLANIP function is imperfect, and has no functions of VLAN ID verification, IP address verification and mask setting, so that error configuration can be issued, the whole network data is not passed, and simultaneously, the database of the switch can be disordered.
And inquiring the configured virtual local area network ID of the white box switch, and forming a VLAN ID table. The configured virtual local area network ID of the white box switch can be inquired in real time, or can be inquired at preset time intervals, and the white box switch can be inquired before a new virtual local area network ID is configured. The queried virtual local area network IDs can be arranged according to a certain sequence to form a VLAN ID table, so that the query of a user is facilitated.
And in response to receiving a command for configuring the virtual local area network, creating a new virtual local area network ID and judging whether the new virtual local area network ID exists in the VLAN ID table. The command to configure the virtual local area network typically includes a VLAN ID, an IP address, and a mask. When a command for configuring the virtual local area network is received, a new virtual local area network ID may be created, but the new virtual local area network ID may already exist in the VLAN ID table, so it is necessary to determine whether the new virtual local area network ID exists in the VLAN ID table, and if the new virtual local area network ID already exists in the VLAN ID table, it may be suggested that the new virtual local area network ID exists.
And responding to the situation that the new virtual local area network ID does not exist in the VLAN ID table, setting the IP address of the new virtual local area network ID, and judging whether the IP address and the IP address which already exists in the VLAN ID table belong to the same network segment. If the new vlan ID does not exist in the vlan ID table, the new vlan ID may be set, and an IP address of the new vlan ID may be set, and the IP address may be referred to as a first IP address in order to be distinguished from other IP addresses. When the first IP address is added, whether the IP address exists under the VLAN interface or not is judged firstly, if the IP address does not exist, the first IP address can be directly added, if the IP address exists, whether the first IP address and the existing IP address belong to the same network segment or not is verified, if the first IP address and the existing IP address do not belong to the same network segment, whether the first IP address is in compliance or not can be verified, and if the compliance rule is configurable, the configuration of the non-compliance rule fails.
And configuring a mask of the IP address in response to the fact that the IP address and the IP address which already exists in the VLAN ID table do not belong to the same network segment. When the IP address does not belong to the same network segment as the IP address already existing in the VLAN ID table, a mask of the IP address can be configured. In some embodiments, said configuring the mask of the IP address comprises: judging whether mask setting exists in the command or not; and in response to the mask setting being present in the command, determining whether the mask setting is a correct number of bits and performing the setting based on the determination. If the specific mask configuration does not exist in the command, the command is issued according to 32 bits, and if the specific mask configuration exists in the command, whether the mask configuration is in compliance is verified, for example, whether the mask configuration is a number within 1-32 can be verified, and if the mask configuration is exceeded, the configuration is failed.
In some embodiments, further comprising: in response to receiving a command to delete an IP address corresponding to an ID, the corresponding IP address is deleted from the vlan ID table. In some embodiments, said removing said corresponding IP address from the VLAN ID table comprises: judging whether the ID corresponding to the ID exists in the VLAN ID table or not; and in response to the presence of an ID corresponding to the ID in the VLAN ID table, determining whether the corresponding IP address is present and performing deletion based on the determination result. In some embodiments, the determining whether the corresponding IP address exists comprises: and judging whether the corresponding IP address has a mask or not.
Fig. 2 is a flowchart illustrating an embodiment of a method for configuring a virtual local area network of a white box switch according to the present invention. As shown in fig. 2, starting at block 101 and proceeding to block 102, the box switch is queried for the virtual local area network ID that it has configured and forms a VLAN ID table; continuing to block 103, in response to receiving a command to configure a virtual local area network, a new virtual local area network ID is created; proceeding to block 104, determining whether the new VLAN ID exists in the VLAN ID table, if yes, ending directly, if no, proceeding to block 105, and setting the IP address of the new VLAN ID; then, the process proceeds to block 106, where it is determined whether the IP address and the existing IP address in the VLAN ID table belong to the same network segment, and if yes, the process ends directly, otherwise, the process proceeds to block 107, where a mask of the IP address is configured, and then the process proceeds to block 108, where the process ends.
It should be particularly noted that, the steps in the embodiments of the method for configuring a whitebox switch vlan described above can be mutually intersected, replaced, added, and deleted, so that these methods for configuring a whitebox switch vlan are also intended to fall within the scope of the present invention, and should not limit the scope of the present invention to the embodiments.
In view of the above object, a second aspect of the embodiments of the present invention provides a computer device, including: at least one processor; and a memory storing computer instructions executable on the processor, the instructions being executable by the processor to perform the steps of: s1, inquiring the configured virtual local area network ID of the white box switch, and forming a VLAN ID table; s2, responding to the command of receiving the configuration virtual local area network, creating a new virtual local area network ID, and judging whether the new virtual local area network ID exists in the VLAN ID table; s3, responding to the VLAN ID table without the new virtual local area network ID, setting the IP address of the new virtual local area network ID, and judging whether the IP address and the IP address already existing in the VLAN ID table belong to the same network segment; and S4, configuring the mask of the IP address in response to the IP address not belonging to the same network segment with the IP address already existing in the VLAN ID table.
In some embodiments, said configuring the mask of the IP address comprises: judging whether mask setting exists in the command or not; and in response to the mask setting being present in the command, determining whether the mask setting is a correct number of bits and performing the setting based on the determination.
In some embodiments, further comprising: in response to receiving a command to delete an IP address corresponding to an ID, the corresponding IP address is deleted from the vlan ID table.
In some embodiments, said removing said corresponding IP address from the VLAN ID table comprises: judging whether the ID corresponding to the ID exists in the VLANID table or not; and in response to the presence of the ID corresponding to the ID in the vlan ID table, determining whether the corresponding IP address is present and performing deletion based on the determination result.
In some embodiments, the determining whether the corresponding IP address exists comprises: and judging whether the corresponding IP address has a mask or not.
Fig. 3 is a schematic hardware structural diagram of an embodiment of the method for configuring a virtual local area network of a white box switch according to the present invention.
Taking the apparatus shown in fig. 3 as an example, the apparatus includes a processor 301 and a memory 302, and may further include: an input device 303 and an output device 304.
The processor 301, the memory 302, the input device 303 and the output device 304 may be connected by a bus or other means, and fig. 3 illustrates the connection by a bus as an example.
The memory 302 is a non-volatile computer-readable storage medium and can be used for storing non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the method for configuring a virtual local area network of a white box switch in the embodiment of the present application. The processor 301 executes various functional applications of the server and data processing by running nonvolatile software programs, instructions and modules stored in the memory 302, that is, implements the method for configuring the virtual local area network of the white box switch of the above-described method embodiment.
The memory 302 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the method of configuring the virtual local area network of the white box switch, and the like. Further, the memory 302 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 302 optionally includes memory located remotely from processor 301, which may be connected to a local module via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 303 may receive information such as a user name and a password that are input. The output means 304 may comprise a display device such as a display screen.
One or more program instructions/modules corresponding to the method for configuring a virtual local area network of a white box switch are stored in the memory 302 and, when executed by the processor 301, perform the method for configuring a virtual local area network of a white box switch in any of the above-described method embodiments.
Any embodiment of a computer device implementing the method for configuring a virtual local area network of a white box switch described above may achieve the same or similar effects as any of the preceding method embodiments corresponding thereto.
The invention also provides a computer readable storage medium storing a computer program which, when executed by a processor, performs the method as above.
Finally, it should be noted that, as one of ordinary skill in the art can appreciate that all or part of the processes of the methods of the above embodiments can be implemented by a computer program to instruct related hardware, and the program of the method for configuring a virtual local area network of a white box switch can be stored in a computer readable storage medium, and when executed, the program can include the processes of the embodiments of the methods described above. The storage medium of the program may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
Furthermore, the methods disclosed according to embodiments of the present invention may also be implemented as a computer program executed by a processor, which may be stored in a computer-readable storage medium. Which when executed by a processor performs the above-described functions defined in the methods disclosed in embodiments of the invention.
Further, the above method steps and system elements may also be implemented using a controller and a computer readable storage medium for storing a computer program for causing the controller to implement the functions of the above steps or elements.
Further, it should be appreciated that the computer-readable storage media (e.g., memory) herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. 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 disclosed embodiments of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the disclosure herein may be implemented or performed with the following components designed to perform the functions herein: a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The steps of a method or algorithm described in connection with the disclosure 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 RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.