Network sharing method, device, electronic device and computer-readable storage medium
By setting the first port for sharing the network, the second port for VPN connection and the third port for external network connection on the first electronic device, the problem that other devices can only access the intranet in VPN technology is solved, and access is achieved Flexibility of both intranet and external network.
Patent Information
- Application Number
- CN202011138462.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-22
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2040-10-22
AI Technical Summary
In the existing VPN technology, other electronic devices can only access the intranet corresponding to the VPN and cannot access the external network, resulting in limited network access.
The first electronic device is provided with the first electronic device for sharing the network with the second electronic device, the second port connected to the VPN, and the third port connected to the external network, and whether to transfer it according to the destination address is to receive the access request and decide whether to convert it. Send to the intranet or external network to realize network access flexibility of the second electronic device.
Through the first electronic device, the access request for the intranet address is sent to the VPN intranet, and the access request for the external network address is sent to the external network, so that the second electronic device can access both the VPN intranet and the external network, thereby improving network access flexibility.
Smart Images

Figure CN112272133B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a network sharing method, device, electronic device, and computer-readable storage medium. Background Art
[0002] Virtual Private Network (VPN) is a remote access technology that uses public networks to build private networks. VPN gateways achieve remote secure access by encrypting data packets and converting data packet destination addresses. It is widely used in enterprise networks.
[0003] Usually, a VPN account can only be logged in on one electronic device. However, with the development of electronic devices, users may own multiple electronic devices at the same time and work collaboratively on multiple electronic devices to improve office efficiency. In the prior art, in order to solve the above problems, an access channel and a VPN channel are set on the main electronic device that logs in to the VPN account, wherein the access channel is used to share the network with other electronic devices, and the VPN channel is used to access the VPN. A connection between the access channel and the VPN channel is established to form a VPN sharing channel, so that other electronic devices can share the VPN with the main electronic device to access the enterprise internal network corresponding to the VPN.
[0004] However, using the existing technology, other electronic devices can only access the intranet corresponding to the VPN and cannot access the external network. Therefore, the network access to other electronic devices is relatively limited. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a network sharing method, apparatus, computer equipment and computer-readable storage medium.
[0006] In a first aspect, the present disclosure provides a network sharing method, which is applied to a first electronic device, wherein the first electronic device is provided with a first port, a second port and a third port, wherein the first port is used for the first electronic device and the second electronic device to share a network, the second port is connected to a virtual private network VPN, and the third port is connected to an external network, the method comprising:
[0007] Receiving an access request sent by the second electronic device through the first port, wherein the access request includes a destination address, and the destination address is an intranet address or an extranet address;
[0008] The access request containing the intranet address is sent to the intranet corresponding to the VPN through the second port; or the access request containing the extranet address is sent to the extranet through the third port.
[0009] Optionally, also include:
[0010] Configuring policy routing, where the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port;
[0011] The step of sending the access request including the intranet address to the intranet corresponding to the VPN through the second port; or sending the access request including the extranet address to the extranet through the third port, comprises:
[0012] Query the routing table of the VPN configured for the second port to determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port to determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
[0013] Optionally, the second port is configured with a VPN routing table and a default route, and the default route points to the third port;
[0014] The step of sending the access request including the intranet address to the intranet corresponding to the VPN through the second port; or sending the access request including the extranet address to the extranet through the third port, comprises:
[0015] querying a routing table of a VPN configured for the second port, determining that the routing table of the VPN does not contain a route corresponding to the destination address, and forwarding the access request to the third port according to the default route;
[0016] The access request is sent to an external network or discarded according to the routing table of the third port.
[0017] Optionally, the method further includes: determining that a routing table of the VPN contains a route corresponding to the destination address, and then sending the access request to a network corresponding to the VPN through the second port.
[0018] Optionally, a forwarding relationship is established between the first port and the second port, and a forwarding relationship is established between the first port and the third port;
[0019] The step of sending the access request including the intranet address to the intranet corresponding to the VPN through the second port; or sending the access request including the extranet address to the extranet through the third port, comprises:
[0020] Determine, according to the destination address in the access request, whether the destination address belongs to an intranet address or an extranet address;
[0021] Sending the access request belonging to the intranet address to the second port, so that the second port sends the access request to the intranet corresponding to the VPN according to the routing table of the VPN;
[0022] The access request belonging to the external network address is sent to the third port, so that the third port sends it to the external network according to the routing table of the third port.
[0023] Optionally, determining, according to the destination address in the access request, that the destination address belongs to an intranet address or an extranet address includes:
[0024] According to the network segment to which the destination address in the access request belongs, the network segment of the intranet and the network segment of the extranet corresponding to the VPN, it is determined whether the destination address belongs to an intranet address or an extranet address.
[0025] In a second aspect, the present disclosure provides a network sharing device, which is applied to a first electronic device, wherein the first electronic device is provided with a first port, a second port and a third port, wherein the first port is used for the first electronic device and the second electronic device to share a network, the second port is connected to a virtual private network VPN, and the third port is connected to an external network, and the device comprises:
[0026] A receiving module, configured to receive an access request sent by a second electronic device through the first port, wherein the access request includes a destination address, and the destination address is an intranet address or an extranet address;
[0027] The sending module is used to send the access request containing the intranet address to the intranet corresponding to the VPN through the second port; or send the access request containing the external network address to the external network through the third port.
[0028] Optionally, also include:
[0029] A configuration module, used to configure policy routing, wherein the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port;
[0030] The sending module is specifically used to query the routing table of the VPN configured for the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port, determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
[0031] Optionally, the second port is configured with a VPN routing table and a default route, and the default route points to the third port;
[0032] The sending module is specifically used to query the routing table of the VPN configured by the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, forward the access request to the third port according to the default route; and send the access request to the external network or discard it according to the routing table of the third port.
[0033] Optionally, also include:
[0034] The sending module is further configured to determine that the routing table of the VPN contains a route corresponding to the destination address, and then send the access request to a network corresponding to the VPN through the second port.
[0035] Optionally, a forwarding relationship is established between the first port and the second port, and a forwarding relationship is established between the first port and the third port;
[0036] The sending module is specifically used to determine whether the destination address belongs to an intranet address or an extranet address according to the destination address in the access request; send the access request belonging to the intranet address to the second port, so that the second port sends the access request to the intranet corresponding to the VPN according to the routing table of the VPN; send the access request belonging to the extranet address to the third port, so that the third port sends it to the extranet according to the routing table of the third port.
[0037] Optionally, the sending module is specifically used to determine whether the destination address in the access request belongs to an intranet address or an extranet address according to the network segment to which the destination address in the access request belongs, the intranet segment and the extranet segment corresponding to the VPN.
[0038] In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the steps of the method described in the first aspect when executing the computer program stored in the memory.
[0039] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0040] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0041] By simultaneously setting a first port for the first electronic device and the second electronic device to share a network, a second port connected to a VPN, and a third port connected to an external network on the first electronic device, when an access request sent by the second electronic device is received through the first port, the access request containing the intranet address is sent to the intranet corresponding to the VPN through the second port, and the access request containing the external network address is sent to the external network through the third port. In this way, the second electronic device can access the intranet corresponding to the VPN through the first electronic device, and can also access the external network through the first electronic device, making the network access of the second electronic device more flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0044] Figure 1 A schematic diagram of a network architecture provided by the present disclosure;
[0045] Figure 2 A schematic diagram of a flow chart of an embodiment of a network sharing method provided by the present disclosure;
[0046] Figure 3 A flowchart of another network sharing method embodiment provided by the present disclosure;
[0047] Figure 4 A flowchart of another network sharing method embodiment provided by the present disclosure;
[0048] Figure 5 A schematic diagram of the structure of a network sharing device provided by the present disclosure;
[0049] Figure 6 A schematic diagram of the structure of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0050] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0051] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0052] The application scenario of the present disclosure is that an electronic device can log in to a VPN account and access the intranet corresponding to the VPN, wherein the intranet can be, for example, an enterprise, an institution, a school or a hospital, and the electronic device can also access the external network, and the ports for accessing the external network and the ports for accessing the intranet through the VPN are different ports. Other electronic devices want to access the external network or the intranet corresponding to the VPN through the electronic device. For the sake of ease of description, the electronic device that logs in to the VPN account is referred to as the first electronic device in the present disclosure, and the other electronic devices are referred to as the second electronic device. The technical solution of the present disclosure aims to enable the second electronic device to access both the VPN intranet and the external network through the first electronic device.
[0053] The first electronic device disclosed in the present invention at least has a function of realizing network sharing, and the network sharing method may be, for example, wireless fidelity (Wireless Fidelity, wifi), hotspot, Bluetooth, Universal Serial Bus (Universal Serial Bus, USB), etc.
[0054] At least three ports are arranged on the first electronic device of the present invention, wherein one port is used for network sharing with the second electronic device, referred to as the first port, another port is used for connecting to a VPN to access the intranet corresponding to the VPN, referred to as the second port, and another port is used for connecting to an external network to access the external network; the second electronic device of the present invention sends an access request to the first electronic device through the first port to request access to the intranet or the external network, and the first electronic device forwards the access request of the second electronic device to the intranet through the second port, or forwards it to the external network through the third port according to the policy set by itself, thereby enabling the second electronic device to access both the external network and the intranet through the network shared by the first electronic device, thereby improving the flexibility of the second electronic device in accessing the network.
[0055] Figure 1 A network architecture diagram provided by the present disclosure, wherein a first electronic device is provided with a first port 101, a second port 102 and a third port 103, wherein the first port is used for the first electronic device and the second electronic device to share a network, the first port can be a wifi port, a hotspot port, a Bluetooth port and a USB port, etc., the second port is connected to a VPN to access the intranet corresponding to the VPN, and the third port is connected to an external network. The third port can be a wireless local area network (WLAN) network port, a mobile network port or an Ethernet port, etc.
[0056] Figure 2 This is a flow chart of an embodiment of a network sharing method provided by the present disclosure. The method of this embodiment is executed by a first electronic device. The method of this embodiment is as follows:
[0057] S201: receiving an access request sent by a second electronic device through a first port.
[0058] The access request includes a destination address, and the destination address is an intranet address or an extranet address. Optionally, the destination address may be a destination IP address. Usually, the internal and external networks have different addresses, and the destination address may be used to determine whether the second electronic device wants to access the intranet or the extranet.
[0059] S202: Send the access request containing the intranet address to the intranet corresponding to the VPN through the second port; or send the access request containing the extranet address to the extranet through the third port.
[0060] If the destination address included in the access request is an intranet address, the access request is sent to the intranet corresponding to the VPN through the second port; if the destination address included in the access request is an extranet address, the access request is sent to the extranet through the third port.
[0061] Since the second electronic device of the present invention accesses the intranet corresponding to the VPN or accesses the external network by sharing the network of the first electronic device, before sending the access request to the intranet corresponding to the VPN through the second port, it also includes: converting the source address of the access request to the source address of the VPN; before sending the access request to the external network through the third port, it also includes: converting the source address of the access request to the source address of the third port.
[0062] In this embodiment, a first port for the first electronic device and the second electronic device to share a network, a second port connected to a VPN, and a third port connected to an external network are simultaneously set on the first electronic device. When an access request sent by the second electronic device is received through the first port, the access request containing the intranet address is sent to the intranet corresponding to the VPN through the second port, and the access request containing the external network address is sent to the external network through the third port. In this way, the second electronic device can access the intranet corresponding to the VPN through the first electronic device, and can also access the external network through the first electronic device, making the network access of the second electronic device more flexible.
[0063] Figure 3 A flowchart of another network sharing method embodiment provided by the present disclosure is provided. Figure 3 is Figure 2Based on the illustrated embodiment, a possible implementation of S202 is described. In this embodiment, a forwarding relationship is established between the first port and the second port and the third port respectively to form a dual shared channel, and a routing table is configured for the second port and the third port; and a policy routing is set, and the priority of the routing table of the VPN of the second port is higher than the priority of the routing table of the third port, that is, the routing table of the VPN of the second port is searched first, and if there is no routing table of the third port, the routing table is searched again, such as Figure 3 As shown, the method of this embodiment includes:
[0064] S2021a: According to the priority of the policy routing, query the routing table of the VPN configured for the second port to determine whether the routing table of the VPN contains a route corresponding to the destination address. If so, execute S2022a; if not, execute S2023a.
[0065] S2022a: Send the access request to the intranet corresponding to the VPN through the second port.
[0066] S2023a: query the routing table of the third port to determine whether the routing table corresponding to the third port contains the route corresponding to the destination address, if so, execute S2024a. If not, execute S2025a.
[0067] S2024a: Forward the access request to the third port, and send it to the external network through the third port.
[0068] S2025a: Discard the access request.
[0069] Since a forwarding relationship is established between the first port and the second port and the third port respectively to form a dual shared channel, the source address of the access request will be converted into the source address of the VPN before the first port sends an access request to the second port; if the access request is forwarded to the third port, the source address of the access request will be converted into the source address of the third port before being sent to the external network through the third port, thereby enabling the second electronic device to share the network of the first electronic device.
[0070] In this embodiment, the VPN routing table is queried first according to the priority of the policy routing through the access request received from the first port. If there is a route corresponding to the destination address in the VPN routing table, the access request is sent to the VPN corresponding intranet through the second port. If there is no route corresponding to the destination address in the VPN routing table, the access request is sent to the external network through the third port. Thus, by setting the priority of the policy routing, the access efficiency of the intranet can be improved, and the access to the external network can be realized at the same time. In addition, the technical solution of this embodiment has little change to the technical solution of the prior art and is easy to implement.
[0071] Optional, in Figure 3An alternative solution in the illustrated embodiment is that the second port is configured with a VPN routing table and a default route, the default route points to the third port, if there is a route corresponding to the destination address in the VPN routing table, the access request is sent to the VPN corresponding intranet through the second port, if there is no route corresponding to the destination address in the VPN routing table, the access request is sent to the third port, the routing table of the third port is queried, and the access request is sent to the external network or discarded according to the routing table of the third port, if the routing table contains a route corresponding to the destination address, the access request is sent to the external network through the third port, if the routing table does not contain a route corresponding to the destination address, the access request is discarded. By configuring the default route, the time for querying the routing table can be saved and the efficiency of forwarding access requests can be improved.
[0072] Figure 4 A flowchart of another network sharing method embodiment provided by the present disclosure is shown below. Figure 4 is Figure 2 On the basis of the illustrated embodiment, further, another possible implementation of S202 is described. In this embodiment, a forwarding relationship is established between the first port and the second port, and a forwarding relationship is also established between the first port and the third port. A policy routing is set at the first port, and the policy request is used to indicate whether to forward to the second port or the third port according to the network segment to which the destination address of the access request belongs. Figure 4 As shown, the method of this embodiment includes:
[0073] S2021b: Determine, based on the destination address in the access request, whether the destination address belongs to an intranet address or an extranet address.
[0074] Specifically, a possible implementation method is: it can be determined according to whether the network segment to which the destination address belongs belongs to the network segment of the intranet or the network segment of the extranet;
[0075] For example: the network segment of the intranet corresponding to VPN is: 172.16.XX; the network segment of the extranet is: 169.254.XX; for example: if the destination address in the received access request is: 169.254.200.81, then it is determined that the network segment to which the destination address belongs is the network segment to which the extranet belongs, and it is determined that the destination address belongs to the extranet address; if the destination address in the received access request is: 172.16.16.20, then it is determined that the network segment to which the destination address belongs is the network segment to which the intranet belongs, and it is determined that the destination address belongs to the intranet address.
[0076] Another possible implementation method: the routing table corresponding to the VPN and the routing table corresponding to the third port can be queried according to the destination address. If the routing table corresponding to the VPN contains the corresponding route, it is determined to be an intranet address. If the routing table corresponding to the third port contains the corresponding route, it is determined to be an external network address. If the routing table corresponding to the VPN and the routing table corresponding to the third port do not contain the address, it is discarded.
[0077] Another possible implementation method is to query the routing table corresponding to the VPN according to the destination address. If the routing table corresponding to the VPN contains the corresponding route, it is determined to be an intranet address. If the routing table corresponding to the VPN does not contain the corresponding route, it is determined to be an extranet address.
[0078] S2022b: Send the access request belonging to the intranet address to the second port, so that the second port sends it to the intranet corresponding to the VPN according to the VPN routing table.
[0079] S2023b: Send the access request belonging to the external network address to the third port, so that the third port sends it to the external network according to the routing table of the third port.
[0080] Since the second electronic device of the present invention accesses the intranet corresponding to the VPN or accesses the external network by sharing the network of the first electronic device, before the second port sends it to the intranet corresponding to the VPN according to the routing table of the VPN, it also includes: converting the source address of the access request into the source address of the VPN; before the third port sends it to the external network according to the routing table of the third port, it also includes: converting the source address of the access request into the source address of the third port.
[0081] In this embodiment, by establishing a connection between the first port and the second port, and establishing a connection between the first port and the third port, after receiving an access request through the first port, the access request is first sent to the corresponding port based on whether the destination address in the access request belongs to the intranet or the extranet. In this way, the second electronic device can access the intranet corresponding to the VPN through the first electronic device, and can also access the extranet through the first electronic device, making the network access of the second electronic device more flexible.
[0082] Figure 5 This is a structural schematic diagram of a network sharing device provided by the present disclosure. The device of this embodiment is applied to a first electronic device, and is characterized in that a first port, a second port and a third port are provided on the first electronic device, wherein the first port is used for the first electronic device and the second electronic device to share a network, the second port is connected to a virtual private network VPN, and the third port is connected to an external network. The device of this embodiment includes: a receiving module 501 and a sending module 502.
[0083] The receiving module 501 is used to receive an access request sent by the second electronic device through the first port, wherein the access request includes a destination address, and the destination address is an intranet address or an extranet address;
[0084] The sending module 502 is used to send the access request containing the intranet address to the intranet corresponding to the VPN through the second port; or send the access request containing the external network address to the external network through the third port.
[0085] Optionally, also include:
[0086] The configuration module 503 is used to configure policy routing, where the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port;
[0087] The sending module 502 is specifically used to query the routing table of the VPN configured for the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port, determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
[0088] Optionally, the second port is configured with a VPN routing table and a default route, and the default route points to the third port;
[0089] The sending module 502 is specifically used to query the routing table of the VPN configured for the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, forward the access request to the third port according to the default route; and send the access request to the external network or discard it according to the routing table of the third port.
[0090] Optionally, also include:
[0091] The sending module 502 is further configured to determine that the routing table of the VPN contains a route corresponding to the destination address, and then send the access request to a network corresponding to the VPN through the second port.
[0092] Optionally, a forwarding relationship is established between the first port and the second port, and a forwarding relationship is established between the first port and the third port.
[0093] The sending module 502 is specifically used to determine whether the destination address belongs to an intranet address or an extranet address based on the destination address in the access request; send the access request belonging to the intranet address to the second port, so that the second port sends the access request to the intranet corresponding to the VPN according to the routing table of the VPN; send the access request belonging to the extranet address to the third port, so that the third port sends it to the extranet according to the routing table of the third port.
[0094] Optionally, the sending module 502 is specifically used to determine whether the destination address in the access request belongs to an intranet address or an extranet address according to the network segment to which the destination address in the access request belongs, the intranet segment corresponding to the VPN, and the extranet segment.
[0095] The apparatus of the above embodiment can be used to perform Figure 2-Figure 4 The technical solution of the method embodiment has similar implementation principles and technical effects, which will not be repeated here.
[0096] Figure 6 601 and a processor 602. The memory 601 is used to store computer programs. The processor 602 is used to execute the computer programs stored in the memory. Figure 2-Figure 4 The steps of any of the methods described above.
[0097] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements Figure 2-Figure 4 The steps of any of the methods described above.
[0098] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0099] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A network sharing method, applied to a first electronic device, characterized in that: The first electronic device is provided with a first port, a second port and a third port, wherein the first port is used for the first electronic device and the second electronic device to share a network, the second port is connected to a virtual private network VPN, and the third port is connected to an external network, and the method includes: Receiving an access request sent by the second electronic device through the first port, wherein the access request includes a destination address, and the destination address is an intranet address or an extranet address; Sending the access request containing the intranet address to the intranet corresponding to the VPN through the second port; or sending the access request containing the extranet address to the extranet through the third port; Configuring policy routing, where the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port; The step of sending the access request including the intranet address to the intranet corresponding to the VPN through the second port; or sending the access request including the extranet address to the extranet through the third port, comprises: Query the routing table of the VPN configured for the second port to determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port to determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
2. The method according to claim 1, characterized in that: The second port is configured with a VPN routing table and a default route, and the default route points to the third port; The access request containing the intranet address is sent to the intranet corresponding to the VPN through the second port; Alternatively, an access request containing an external network address is sent to the external network through a third port, including: querying a routing table of a VPN configured for the second port, determining that the routing table of the VPN does not contain a route corresponding to the destination address, and forwarding the access request to the third port according to the default route; The access request is sent to an external network or discarded according to the routing table of the third port.
3. The method according to claim 1 or 2, characterized in that: Also includes: If it is determined that the routing table of the VPN contains the route corresponding to the destination address, the access request is sent to the network corresponding to the VPN through the second port.
4. The method according to claim 1, characterized in that: A forwarding relationship is established between the first port and the second port, and a forwarding relationship is established between the first port and the third port; The access request containing the intranet address is sent to the intranet corresponding to the VPN through the second port; Alternatively, an access request containing an external network address is sent to the external network through a third port, including: Determine, according to the destination address in the access request, whether the destination address belongs to an intranet address or an extranet address; Sending the access request belonging to the intranet address to the second port, so that the second port sends the access request to the intranet corresponding to the VPN according to the routing table of the VPN; The access request belonging to the external network address is sent to the third port, so that the third port sends it to the external network according to the routing table of the third port.
5. The method according to claim 4, characterized in that The determining, according to the destination address in the access request, that the destination address belongs to an intranet address or an extranet address includes: According to the network segment to which the destination address in the access request belongs, the network segment of the intranet and the network segment of the extranet corresponding to the VPN, it is determined whether the destination address belongs to an intranet address or an extranet address.
6. A network sharing device, applied to a first electronic device, characterized in that: The first electronic device is provided with a first port, a second port and a third port, wherein the first port is used for the first electronic device and the second electronic device to share a network, the second port is connected to a virtual private network VPN, and the third port is connected to an external network, and the device comprises: A receiving module, configured to receive an access request sent by a second electronic device through the first port, wherein the access request includes a destination address, and the destination address is an intranet address or an extranet address; A sending module, used to send an access request containing an intranet address to an intranet corresponding to the VPN through a second port; or to send an access request containing an extranet address to an extranet through a third port; A configuration module, used to configure policy routing, wherein the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port; The sending module is specifically used to query the routing table of the VPN configured for the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port, determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
7. The device according to claim 6, characterized in that Also includes: A configuration module, used to configure policy routing, wherein the policy routing is used to indicate that the priority of the routing table of the VPN configured on the second port is higher than the routing table of the third port; The sending module is specifically used to query the routing table of the VPN configured for the second port, determine that the routing table of the VPN does not contain the route corresponding to the destination address, query the routing table corresponding to the third port, determine that the routing table corresponding to the third port contains the route corresponding to the destination address, and then forward the access request to the third port to send it to the external network.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the steps of the method according to any one of claims 1 to 5 when executing the computer program stored in the memory.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Message forwarding method and device
CN105991442A
Virtual private network routing method, device and system, equipment and storage medium
CN111711556A
Anti-spoofing techniques for overlay networks
US10764249B1
