A Method for Accessing Devices in the Same Network Segment, an Electronic Device, and a Storage Medium
By identifying and filtering all network devices in the same network segment, combining network card service information and IP addresses, directive access to the target network devices is achieved, IP address conflict issues are solved, and correct device access is ensured.
Patent Information
- Application Number
- CN202510185745.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2045-02-20
AI Technical Summary
In the case of multiple network cards, when different network devices have the same gateway address, it will lead to IP address conflicts, resulting in the actual access to the network device may not be the network device that needs to be accessed.
By identifying all network devices in the same network segment, multiple target network devices are selected, and each target network device is accessed based on the preset network card service information and the IP address of the target network device. The network card service information represents the service priority order of the network card connected to each target network device. Through this information, the target address of the target network device is determined to achieve directive access to the target network device.
It solves the problem of IP address conflicts in the access of devices in the same network segment, ensuring that the network device you need to access through the correct address in the same network segment can be accessed.
Smart Images

Figure CN119676215B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text processing, and in particular to a method for accessing devices in the same network segment, an electronic device, and a computer-readable storage medium. Background Art
[0002] Currently, when a client accesses a network device through a specified IP address in the case of multiple network cards, if different network devices have the same gateway address, there will be an IP address conflict, resulting in the possibility that the actually accessed network device may not be the network device to be accessed. Summary of the Invention
[0003] The present invention aims to solve at least one of the technical problems in the related art to some extent. For this purpose, the present invention provides a method for accessing devices in the same network segment, an electronic device, and a storage medium, which can access the network device to be accessed through the correct address in the case of the same network segment.
[0004] In a first aspect, an embodiment of the present invention provides a method for accessing devices in the same network segment, including:
[0005] Performing identification processing on all network devices in the same network segment, so as to screen out multiple target network devices from all the network devices;
[0006] In the case of determining that the IP addresses of all the target network devices are the same, accessing each of the target network devices according to the preset network card service information and the IP address of the target network device, where the network card service information represents the order of service priorities of the network cards to which each of the target network devices is connected.
[0007] Optionally, in an embodiment of the present invention, the accessing each of the target network devices according to the preset network card service information and the IP address of the target network device includes:
[0008] Determining a corresponding first target network device from all the target network devices according to the obtained device access information, where the first target network device is one of the target network devices to be accessed;
[0009] Determining a first service priority according to the preset network card service information, where the first service priority is the service priority of the network card to which the first target network device is connected;
[0010] Accessing the first target network device according to the first service priority and the IP address of the first target network device.
[0011] Optionally, in an embodiment of the present invention, the accessing the first target network device according to the first service priority and the IP address of the first target network device includes:
[0012] When the first service priority is the highest, access the first target network device through the IP address of the first target network device.
[0013] Optionally, in an embodiment of the present invention, the accessing the first target network device according to the first service priority and the IP address of the first target network device includes:
[0014] When the first service priority is not the highest, determine the number of network cards to which the first target network device is connected, and access the first target network device according to the number of network cards to which the first target network device is connected and the IP address of the first target network device.
[0015] Optionally, in an embodiment of the present invention, the accessing the first target network device according to the number of network cards to which the first target network device is connected and the IP address of the first target network device includes:
[0016] When the first target network device is connected to one network card, switch the IP address of the first target network device to the private domain name address of the first target network device, and access the first target network device through the private domain name address of the first target network device;
[0017] Or,
[0018] When the first target network device is connected to multiple network cards, determine whether there is one network card to which the first target network device is connected and the service priority of which is the highest. If so, access the first target network device through the IP address of the first target network device; otherwise, switch the IP address of the first target network device to the private domain name address of the first target network device, and access the first target network device through the private domain name address of the first target network device.
[0019] Optionally, in an embodiment of the present invention, the accessing the first target network device according to the first service priority and the IP address of the first target network device includes:
[0020] When the first service priority is not the highest and the IP address of the first target network device is a subnet address of the IP address of the second target network device, switch the IP address of the first target network device to the private domain name address of the first target network device, and access the first target network device through the private domain name address of the first target network device, where the second target network device is one of the target network devices with the highest service priority among the connected network cards.
[0021] Optionally, in an embodiment of the present invention, the identifying and processing all network devices in the same network segment to screen out multiple target network devices from all the network devices includes:
[0022] Sending UDP broadcast messages to the port numbers corresponding to all network devices in the same network segment respectively;
[0023] Receiving the feedback information sent by each of the network devices according to the UDP broadcast message respectively, where each piece of feedback information carries the IP address of the corresponding network device;
[0024] Screening all the network devices according to the pre-determined IP addresses of each target network device and all the feedback information to obtain multiple target network devices.
[0025] In a second aspect, an embodiment of the present invention provides an electronic device, including:
[0026] At least one processor;
[0027] At least one memory for storing at least one program;
[0028] When at least one of the programs is executed by at least one of the processors, the method for accessing devices in the same network segment as described in the first aspect is implemented.
[0029] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a program executable by a processor is stored, and when the program executable by the processor is executed by the processor, it is used to implement the method for accessing devices in the same network segment as described in the first aspect.
[0030] A method for accessing devices in the same network segment, an electronic device, and a storage medium proposed by the present invention identify and process all network devices in the same network segment to screen out multiple target network devices. Then, in the case of the same network segment, according to the preset network card service information and the same IP address of each target network device, each target network device is accessed. Since the network card service information represents the order of service priorities of the network cards to which each target network device is respectively connected, the target address corresponding to the target network device can be determined through the network card service information and the IP address of the target network device. Then, based on the target address, a targeted access to the target network device is realized, thereby solving the IP address conflict problem in accessing devices in the same network segment and enabling the required network device to be accessed through the correct address in the case of the same network segment. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is a flowchart of the method for accessing devices in the same network segment provided by an embodiment of the present invention;
[0032] Figure 2 is a schematic diagram of an application scenario of the method for accessing devices in the same network segment provided by an embodiment of the present invention;
[0033] Figure 3 is Figure 1 a flowchart of step S1000 in
[0034] Figure 4 is Figure 1 a flowchart of step S2000 in
[0035] Figure 5 is Figure 4 a flowchart of step S2300 in
[0036] Figure 6 is a schematic diagram of an application scenario of the method for accessing devices in the same network segment provided by another embodiment of the present invention;
[0037] Figure 7 is Figure 4 a flowchart of another step S2300 in
[0038] Figure 8 is Figure 4 a flowchart of another step S2300 in
[0039] Figure 9 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0041] It should be noted that although functional module division is carried out in the device schematic diagram and the logical sequence is shown in the flowchart, in some cases, the steps shown or described can be executed in a different module division in the device or a different order in the flowchart.
[0042] Figure 1 The flowchart of the method for accessing devices in the same network segment provided by an embodiment of the present invention. The method for accessing devices in the same network segment may include, but is not limited to, steps S1000 and S2000.
[0043] Step S1000: Identify and process all network devices in the same network segment, so as to screen out multiple target network devices from all network devices. Among them, the number, specifications and functions of the network devices are not limited and can be set accordingly according to the actual application scenario. For example, each network device may, but is not limited to, integrate functions such as MAC address learning and forwarding of switches, VLAN division and Trunk technology functions, or static route configuration functions of routers. This part of the functions is related prior art and will not be elaborated here.
[0044] Step S2000: When it is determined that the IP addresses of each target network device are the same, access each target network device according to the preset network card service information and the IP address of the target network device. Among them, the network card service information represents the high-low order of the service priorities of the network cards to which each target network device is respectively connected.
[0045] It should be noted that the IP address is used to identify devices in the network, the network segment defines the scope and boundary of the network, and the network card is a physical layer device responsible for the physical transmission and processing of data. These three together constitute the basic structure and communication mechanism of the network. Since the relationships between the IP address and the network segment, the network card and the IP address, and the network segment and the network card are well known to those skilled in the art, for the sake of avoiding redundancy, they will not be elaborated here.
[0046] The execution subject of the method for accessing devices in the same network segment provided by this embodiment can be various and can be determined accordingly according to the actual application scenario requirements. For example, referring to Figure 2 , using the computer cloud as the execution subject of the method for accessing devices in the same network segment. The computer cloud can be used to configure and connect multiple network cards (i.e., Figure 2Network cards 1, 2, …, N shown in [figure], different network cards form corresponding service orders according to preset network card service information, so that the computer cloud performs configuration connection with each network card based on the preset service order, or, by executing the same-segment device access method through a client (such as a user terminal, etc.), the network card service information and its configuration method can refer to Figure 2 For similar settings with the examples in [reference], there is no limitation here.
[0047] In this step, by identifying and processing all network devices in the same segment to screen out multiple target network devices, and then in the case of the same segment, according to the preset network card service information and the same IP addresses of each target network device, access each target network device. Since the network card service information represents the high-low order of the service priorities of the network cards to which each target network device is respectively connected, the target address corresponding to the target network device can be determined through the network card service information and the IP address of the target network device, and then based on the target address, the targeted access to the target network device can be realized, thus solving the IP address conflict problem of accessing devices in the same segment, and being able to access the required network device through the correct address in the case of the same segment.
[0048] In an embodiment, the number, type, specifications, etc. of the target network devices are not limited, and can be correspondingly screened and determined according to the actual application scenario, that is, this embodiment does not limit which specific network devices the target network devices are. For example, multiple different-specification Aizhi devices produced by Yihui Company are used as target network devices, and other wireless gateway devices, ordinary gateway devices, etc. are used as other network devices different from the target network devices.
[0049] An embodiment of the present invention, as Figure 3 shown, step S1000 may include but is not limited to steps S1100 to S1300.
[0050] Step S1100: Send UDP broadcast messages to the port numbers corresponding to all network devices in the same segment respectively;
[0051] Step S1200: Receive the feedback information sent by each network device according to the UDP broadcast message respectively, where each feedback information carries the IP address of the corresponding network device;
[0052] Step S1300: Screen all network devices according to the pre-determined IP addresses of each target network device and all feedback information to obtain multiple target network devices.
[0053] In this step, when it is determined that each network device is connected to the corresponding local area network, UDP is enabled at this time, so that UDP broadcast messages can be sent to the port numbers corresponding to all network devices in the same network segment respectively. When a network device receives a UDP broadcast message, it will send corresponding feedback information, and the feedback information carries the IP address of the corresponding network device at the same time. Therefore, the IP addresses of each network device can be obtained by obtaining the feedback information. Since the IP addresses of each target network device are pre-determined (for example, the IP address of the Aizhi device is fixed), then only need to compare the IP address of the network device in the feedback information with the pre-determined IP addresses of each target network device, and multiple target network devices can be screened out. Among them, UDP broadcast message sending, feedback information receiving, etc. can be implemented based on, but not limited to, the ARP protocol (Address Resolution Protocol), LLDP protocol (Link Layer Discovery Protocol), DHCP protocol (Dynamic Host Configuration Protocol), or SNMP protocol (Simple Network Management Protocol), etc.; when discovering network devices in the same network segment, it can be implemented by, but not limited to, using relevant device management software (such as eSight, Works, etc., which can automatically discover network devices in the same network segment and provide detailed information and configuration management functions of the corresponding devices, facilitating the identification, connection, and management of network devices), comprehensive network management platforms (such as SolarWinds, OpenNMS, etc., which can monitor and manage the entire network, including functions such as automatic discovery of network devices in the same network segment, performance monitoring, and fault diagnosis, can quickly locate and connect to network devices, and perform corresponding management operations), etc.; when finding the port numbers corresponding to each network device for identification, it can be implemented by network scanning tools (such as AdvancedIPScanner, NetBScanner), port scanning tools (such as Nmap), or packet capture tools (such as Wireshark), etc.
[0054] An embodiment of the present invention, as Figure 4 shown, step S2000 may include, but not be limited to, steps S2100 to S2300.
[0055] Step S2100: Determine the corresponding first target network device from all target network devices according to the obtained device access information, where the first target network device is one of the target network devices to be accessed;
[0056] Step S2200: Determine the first service priority according to the preset network card service information, where the first service priority is the service priority of the network card to which the first target network device is connected;
[0057] Step S2300: Access the first target network device according to the first service priority and the IP address of the first target network device.
[0058] In this step, the target network device to be accessed is determined from all target network devices through device access information. At the same time, since the network card service information represents the order of service priorities of the network cards respectively connected to each target network device, the service priority of the network card connected to the target network device to be accessed can be determined through the preset network card service information, so that the first target network device can be accessed correctly and effectively according to the first service priority and the IP address of the first target network device.
[0059] In an embodiment, the source channel, specific content, etc. of the device access information need to be determined according to the actual application scenario, which is not limited here. For example, when the computer cloud is used as the execution entity, the user reports the device access information to the computer cloud to inform the computer cloud of the target network device to be accessed. Or, for access testing, the device access information can be randomly generated, or the device access information is pre-set according to the actual scenario, etc.
[0060] It should be noted that for the case where the first target network device is multiple or multiple first target network devices can be determined according to the device access information, the step principle is similar to that of steps S2100 to S2300 provided in the above embodiment, and the difference is only in the number of the first target network devices. In the actual application process, each first target network device can be accessed separately based on steps S2100 to S2300, which will not be elaborated here.
[0061] An embodiment of the present invention, as Figure 5 shown, step S2300 may include but is not limited to step S2310.
[0062] Step S2310: When the first service priority is the highest, access the first target network device through the IP address of the first target network device.
[0063] Specifically, as Figure 6 shown, network cards 1 to N are respectively connected to corresponding network devices, where network cards 1 to 4 are respectively connected to different first target network devices (i.e., Figure 6The devices 1, 2, and 3 shown (for example, all are Aizhi devices), network cards 5 to N are respectively connected to other network devices (such as network card 5 is connected to other wireless gateway devices, network card N is connected to other gateway devices, etc.). It can be seen that the gateway service addresses (i.e., IP addresses) of devices 1 and 2 are the same, both being 192.168.128.1, and the IP address of device 3 is 192.168.128.10. As the subnet address of 192.168.128.1, its IP address is equivalent to 192.168.128.1, that is, in this case, it can be determined that the IP addresses of devices 1, 2, and 3 are the same; assume that in a specific application scenario, network card 3 in the Wi-Fi connection state is disconnected. At this time, device 1, device 2 in the wired connection state (i.e., device 2 connected to network card 2), and device 3 are analyzed. If the service priorities of the network cards they are respectively connected to are sorted from high to low as: network card 1 > network card 2 > network card 4, then when device 1 is determined to be the first target network device according to the device access information, since the service priority of network card 1 connected to device 1 is the highest, device 1 can be directly accessed correctly through the IP address of device 1.
[0064] An embodiment of the present invention, as Figure 7 shown, step S2300 may include but is not limited to step S2320.
[0065] Step S2320, when the first service priority is not the highest, determine the number of network cards connected to the first target network device, and access the first target network device according to the number of network cards connected to the first target network device and the IP address of the first target network device.
[0066] In this step, when the first service priority is not the highest, it means that at this time, the first target network device cannot be directly accessed through its IP address. Therefore, further determine the number of network cards corresponding to the first target network device, so as to access the first target network device correctly according to the number of network cards corresponding to the first target network device and the IP address of the first target network device. That is to say, whether the first service priority is the highest or not, the same-segment device access method provided by the embodiments of the present invention can be applied, so as to ensure that the first target network device can be accessed correctly.
[0067] In an embodiment, when the first service priority is not the highest, when the first target network device is connected to one network card, switch the IP address of the first target network device to the private domain name address of the first target network device, and access the first target network device through the private domain name address of the first target network device.
[0068] Specifically, as Figure 6As shown, assume that in a specific application scenario, the network card 3 under the Wi-Fi connection state is disconnected. At this time, device 1, device 2 in the wired connection state (i.e., device 2 connected to network card 2), and device 3 are analyzed. If the service priorities of the network cards they are respectively connected to are sorted from high to low as: network card 1 > network card 2 > network card 4, then when device 2 is determined to be the first target network device according to the device access information, since device 2 is only connected to network card 2 at this time and the service priority of network card 2 is not the highest, while the service priority of network card 1 connected to device 1 is the highest, so if directly connecting through the IP address of device 2, device 1 will be accessed. Therefore, to avoid this situation, the IP address of device 2 is downgraded to its unique private domain name address, so as to correctly access device 2 through the private domain name address of device 2, ensuring that device 2 can be correctly and effectively accessed.
[0069] In an embodiment, when the first service priority is not the highest, when the first target network device is connected to multiple network cards, it is determined whether there is one of the network cards connected to the first target network device with the highest service priority. If so, the first target network device is accessed through the IP address of the first target network device; otherwise, the IP address of the first target network device is switched to the private domain name address of the first target network device, and the first target network device is accessed through the private domain name address of the first target network device.
[0070] Specifically, as Figure 6 shown, assume that in another specific application scenario, network card 3 under the Wi-Fi connection state and network card 2 under the wired connection state are both normally connected. At this time, both network card 2 and network card 3 point to device 2. If the service priorities of each network card are sorted from high to low as: network card 3 > network card 2 > network card 4 > network card 1, then when device 2 is determined to be the first target network device according to the device access information, since device 2 is connected to network card 2 and network card 3 at this time, and the service priority of network card 3 is the highest, so accessing through network card 3 is equivalent to accessing through network card 2, that is, device 2 can be correctly accessed directly through the IP address of device 2; if the service priorities of each network card are sorted from high to low as: network card 1 > network card 2 > network card 4 > network card 3, then when device 2 is determined to be the first target network device according to the device access information, since device 2 is connected to network card 2 and network card 3 at this time, and the service priorities of network card 2 and network card 3 are not the highest, but the service priority of network card 1 connected to device 1 is the highest, so if directly connecting through the IP address of device 2, device 1 will be accessed. Therefore, to avoid this situation, the IP address of device 2 is downgraded to its unique private domain name address, so as to correctly access device 2 through the private domain name address of device 2, ensuring that device 2 can be correctly and effectively accessed.
[0071] An embodiment of the present invention, asFigure 8 As shown, step S2300 may include but is not limited to step S2330.
[0072] Step S2330: When the first service priority is not the highest and the IP address of the first target network device is a subnet address of the IP address of the second target network device, switch the IP address of the first target network device to its private domain name address, and access the first target network device through its private domain name address, where the second target network device is one of the target network devices with the highest service priority among the connected network cards.
[0073] In this step, since the first service priority is not the highest and the IP address of the first target network device is a subnet address of the IP address of the second target network device, if the first target network device is directly accessed by its IP address, it may be misidentified as a subnet device of the second target network device. To avoid this situation, the IP address of the first target network device is switched to its private domain name address, and the first target network device is accessed through its private domain name address, which can ensure correct and effective access to the first target network device.
[0074] Specifically, as Figure 6 shown, the IP address of device 3 is a subnet address of the IP address of device 1. Analyzing device 1, device 2 in a wired connection state (i.e., device 2 connected to network card 2), and device 3, if the service priorities of each network card are sorted from high to low as: network card 1 > network card 4 > network card 2, then when device 3 is determined to be the first target network device based on device access information, if directly connected through the IP address of device 3, it will be judged as a subnet address of the IP address of device 1, thus accessing device 1. Therefore, to avoid this situation, the IP address of device 3 is downgraded to its unique private domain name address, so as to correctly access device 3 through the private domain name address of device 3 to ensure correct and effective access to device 3.
[0075] Figure 9 is a schematic structural diagram of an electronic device 1000 provided by an embodiment of the present invention. As Figure 9 shown, the electronic device 1000 includes a memory 1100 and a processor 1200. The number of the memory 1100 and the processor 1200 may be one or more, Figure 9 taking one memory 1100 and one processor 1200 as an example; the memory 1100 and the processor 1200 in the device may be connected through a bus or other means, Figure 9 taking connection through a bus as an example.
[0076] The memory 1100, being a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the same-network-segment device access method provided in any embodiment of the present invention. The processor 1200 realizes the above-mentioned same-network-segment device access method by running the software programs, instructions, and modules stored in the memory 1100.
[0077] The memory 1100 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function. In addition, the memory 1100 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some instances, the memory 1100 may further include a memory remotely disposed relative to the processor 1200, and these remote memories can be connected to the device through a network. Examples of the above-mentioned network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and their combinations.
[0078] An embodiment of the present invention also provides a computer-readable storage medium storing computer-executable instructions for executing the same-network-segment device access method provided in any embodiment of the present invention.
[0079] An embodiment of the present invention also provides a computer program product including a computer program or computer instructions. The computer program or computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer program or computer instructions from the computer-readable storage medium, and the processor executes the computer program or computer instructions, causing the computer device to execute the same-network-segment device access method provided in any embodiment of the present invention.
[0080] The electronic devices and application scenarios described in the embodiments of the present invention are for more clearly illustrating the technical solutions of the embodiments of the present invention, and do not constitute a limitation to the technical solutions provided in the embodiments of the present invention. Those skilled in the art can know that with the evolution of electronic devices and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present invention are equally applicable to similar technical problems.
[0081] Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, and their appropriate combinations.
[0082] In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be executed by several physical components in cooperation. Some or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, a communication medium typically includes computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium.
[0083] The terms "component", "module", "system", etc. used in this specification are used to denote a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, or a computer. By way of illustration, an application running on a computing device and the computing device can both be components. One or more components can reside in a process or execution thread, and a component can be located on one computer or distributed between two or more computers. In addition, these components can execute from various computer-readable media on which various data structures are stored. A component can communicate, for example, by signals according to one or more data packets (e.g., data from two components interacting from a local system, a distributed system, or another component across a network, such as via the Internet interacting with other systems).
Claims
1. A method for accessing devices in the same network segment, characterized in that: include: Identify and process all network devices in the same network segment, thereby screening and obtaining multiple target network devices from all the network devices; When it is determined that the IP addresses of the target network devices are the same, accessing the target network devices according to preset network card service information and the IP addresses of the target network devices, wherein the network card service information represents the service priority order of the network cards to which the target network devices are respectively connected; Wherein, the accessing each of the target network devices according to the preset network card service information and the IP address of the target network device includes: Determine a corresponding first target network device from all the target network devices according to the acquired device access information, wherein the first target network device is one of the target network devices to be accessed; Determine a first service priority according to preset network card service information, wherein the first service priority is a service priority of the network card to which the first target network device is connected; Accessing the first target network device according to the first service priority and the IP address of the first target network device; The step of accessing the first target network device according to the first service priority and the IP address of the first target network device includes: When the first service priority is not the highest, the number of the network cards connected to the first target network device is determined, and the first target network device is accessed according to the number of the network cards connected to the first target network device and the IP address of the first target network device.
2. The method for accessing devices in the same network segment according to claim 1, characterized in that: The accessing the first target network device according to the first service priority and the IP address of the first target network device also includes: When the first service priority is the highest, the first target network device is accessed through the IP address of the first target network device.
3. The method for accessing devices in the same network segment according to claim 1, characterized in that: The accessing the first target network device according to the number of the network cards connected to the first target network device and the IP address of the first target network device includes: When the first target network device is connected to one of the network cards, the IP address of the first target network device is switched to the private domain name address of the first target network device, and the first target network device is accessed through the private domain name address of the first target network device; or, When the first target network device is connected to multiple network cards, determine whether there is one of the network cards connected to the first target network device with the highest service priority; if so, access the first target network device through the IP address of the first target network device; otherwise, switch the IP address of the first target network device to the private domain name address of the first target network device, and access the first target network device through the private domain name address of the first target network device.
4. The method for accessing devices in the same network segment according to claim 1, characterized in that: The accessing the first target network device according to the first service priority and the IP address of the first target network device also includes: When the first service priority is not the highest and the IP address of the first target network device is the subnet address of the IP address of the second target network device, the IP address of the first target network device is switched to the private domain name address of the first target network device, and the first target network device is accessed through the private domain name address of the first target network device, wherein the second target network device is one of the target network devices with the highest service priority of the connected network card.
5. The method for accessing devices in the same network segment according to claim 1, characterized in that: The identification process is performed on all network devices in the same network segment, thereby screening out multiple target network devices from all the network devices, including: Send UDP broadcast messages to the corresponding port numbers of all network devices in the same network segment; Respectively receiving feedback information sent by each of the network devices according to the UDP broadcast message, wherein each of the feedback information carries the IP address of the corresponding network device; According to the predetermined IP addresses of the respective target network devices and all the feedback information, all the network devices are screened to obtain a plurality of the target network devices.
6. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When at least one of the programs is executed by at least one of the processors, the method for accessing devices in the same network segment as described in any one of claims 1 to 5 is implemented.
7. A computer-readable storage medium, characterized in that: A processor-executable program is stored therein, and when the processor-executable program is executed by the processor, it is used to implement the method for accessing devices in the same network segment as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for configuring multiple network cards
CN106953795A
Data sending method and device, electronic equipment and storage medium
CN117135204A