Network limiting method and device, terminal equipment and storage medium
By monitoring and restricting Internet connections on terminal devices, using iptables commands and simulated packet verification mechanisms, a terminal-level anti-Internet mechanism is implemented, solving the problem of terminals mistakenly accessing the Internet in the existing technology, and enhancing information security.
Patent Information
- Application Number
- CN202310175553.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-02-27
AI Technical Summary
Existing technology cannot implement a universal mechanism to prevent Internet access at the terminal level, causing private network terminals to accidentally access the Internet and lacking effective protective measures.
By monitoring the data connection between the terminal device and the Internet network, execute the iptables command to restrict non-root users and non-system user processes from accessing the Internet, and start multiple threads to send simulated packets to the preset network address. If a return packet is received, the connection will be disconnected. , to implement a terminal-level anti-Internet mechanism.
Effectively prevent unauthorized users from accessing the Internet, ensure the isolation of terminal devices from the Internet, and enhance information security.
Smart Images

Figure CN118555686A
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a network restriction method, apparatus, terminal device and storage medium. Background Art
[0002] Virtual Private Dial Network (VPDN) technology is currently widely used by users in government, enterprises, and regulatory industries. Users use dedicated terminals with built-in dedicated Subscriber Identity Module (SIM) cards, configure dedicated access points (APNs), access the dedicated public data network (PDN) channels provided by operators, and access the enterprise's private network. Some office or business-related applications (APPs) are pre-installed on the terminals to communicate with the servers deployed by the enterprise in the private network.
[0003] At present, there is no comprehensive and unified approach in the industry to prevent private network terminals from accidentally accessing the Internet. Some private network terminals have not even taken any measures. The few methods that have been taken to prevent Internet access remain at the APP level, or they verify the legitimacy of the SIM card, or check whether the private network server is connected, and impose some restrictions on the phone, such as forced screen lock.
[0004] In the prior art, the data connection capability obtained by the terminal depends entirely on the operator, and it is impossible to identify scenarios in which the terminal mistakenly connects to the Internet based on signaling. Therefore, it is impossible to implement a universal mechanism to prevent Internet access at the terminal level. Summary of the invention
[0005] The present application provides a network restriction method, apparatus, terminal device and storage medium to solve the problem that the prior art cannot implement a universal Internet prevention mechanism at the terminal level.
[0006] In a first aspect, an embodiment of the present application provides a network restriction method, which is applied to a terminal device, and the method includes:
[0007] When it is detected that the terminal device is establishing a data connection with the Internet network, a first command is executed, wherein the first command is used to restrict non-root user processes and non-system user processes from accessing the Internet network;
[0008] When it is detected that the data connection is successfully established, N threads are started to send simulation packets to the preset network addresses respectively, where N is a positive integer;
[0009] If any of the threads receives a reply packet corresponding to the simulation packet within a preset time period, the data connection is disconnected.
[0010] In a possible design of the first aspect, the method further includes:
[0011] If any of the threads does not receive a reply packet corresponding to the simulation packet within the preset time period, the data connection is maintained.
[0012] In another possible design of the first aspect, the method further includes:
[0013] When the data connection is disconnected, or the time after the data connection is successfully established is greater than the preset time and the return packet is not received, the first command is reset to lift the restriction on the non-root user's process and the non-system user's process accessing the Internet network.
[0014] In yet another possible design of the first aspect, the network address includes: an address corresponding to an Internet domain name, an Internet Internet Protocol version ipv4 address, and an Internet ipv6 address;
[0015] Accordingly, N is greater than or equal to 3;
[0016] Correspondingly, the starting of N threads to send simulation packets to preset network addresses respectively includes:
[0017] At least three threads are started to send the simulation packet to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address respectively.
[0018] In another possible design of the first aspect, N is 9.
[0019] In another possible design of the first aspect, the first command is an iptables command.
[0020] In a second aspect, an embodiment of the present application provides a network restriction device, which is applied to a terminal device, and the device includes:
[0021] A processing module, configured to execute a first command when detecting that the terminal device is establishing a data connection with the Internet network, wherein the first command is configured to restrict non-root user processes and non-system user processes from accessing the Internet network;
[0022] A startup module, configured to start N threads to send simulation packets to a preset network address respectively upon detecting that the data connection is successfully established, wherein N is a positive integer;
[0023] The disconnection module is used to disconnect the data connection if any of the threads receives a reply packet corresponding to the simulation packet within a preset time period.
[0024] In a possible design of the second aspect, the processing module is further used to:
[0025] If any of the threads does not receive a reply packet corresponding to the simulation packet within the preset time period, the data connection is maintained.
[0026] In another possible design of the second aspect, the release module is used to:
[0027] When the data connection is disconnected, or the time after the data connection is successfully established is greater than the preset time and the return packet is not received, the first command is reset to lift the restriction on the non-root user's process and the non-system user's process accessing the Internet network.
[0028] In another possible design of the second aspect, the network address includes: an address corresponding to an Internet domain name, an Internet IPv4 address, and an Internet IPv6 address;
[0029] Accordingly, N is greater than or equal to 3;
[0030] Accordingly, the startup module is specifically used for:
[0031] At least three threads are started to send the simulation packet to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address respectively.
[0032] In yet another possible design of the second aspect, N is 9.
[0033] In another possible design of the second aspect, the first command is an iptables command.
[0034] In a third aspect, the present application provides a terminal device, comprising: a processor, and a memory and a transceiver communicatively connected to the processor;
[0035] The memory stores computer-executable instructions; the transceiver is used to send and receive data;
[0036] The processor executes the computer-executable instructions stored in the memory to implement the network restriction method as described in the first aspect or any one of the above-mentioned methods.
[0037] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the network restriction method described in the first aspect or any one of the above-mentioned methods.
[0038] The network restriction method, device, terminal device and storage medium provided in the embodiment of the present application are applied to the terminal device. When it is detected that the terminal device is establishing a data connection with the Internet network, a first command is executed, and the first command is used to restrict the process of non-root users and non-system users from accessing the Internet network. After that, when it is detected that the data connection is successfully established, N threads are started to send simulation packets to the preset network address respectively, and N is a positive integer. Finally, if any thread receives a reply packet corresponding to the simulation packet within the preset time, the data connection is disconnected. In this technical solution, ordinary users who access the Internet network are first restricted. After the data connection is successfully established, the packet is simulated to send packets to multiple preset network addresses. If a reply packet is received within a certain period of time, it means that the data connection can access the Internet network, and then it is disconnected, so as to realize the general anti-Internet access mechanism at the terminal level in a double insurance manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0040] Figure 1 A schematic diagram of an application scenario of the network restriction method provided in an embodiment of the present application;
[0041] Figure 2 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 1 ;
[0042] Figure 3 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 2 ;
[0043] Figure 4 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 3 ;
[0044] Figure 5 A schematic diagram of the structure of an embodiment of a network restriction device provided in an embodiment of the present application;
[0045] Figure 6 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application.
[0046] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] Before introducing the embodiments of the present application, the application background involved in the embodiments of the present application is first described:
[0049] With the rapid development of information technology and network technology, the Internet has gradually become the main platform for people to exchange information, and network security issues have become a top priority that needs to be considered in various online activities.
[0050] As the first line of defense for building a secure network environment, the most fundamental and effective way to prove whether the firewall functions effectively and whether its performance meets the requirements is to test it.
[0051] In the prior art, based on the packet filtering function of the firewall, test cases are designed for the test of the effectiveness of firewall rules, the test of the network address translation (NAT) type and the information leakage availability test, and the test methods are analyzed and studied. In the firewall rule effectiveness test, a solution is proposed to use the Extensible Markup Language (XML) technology to establish a general test platform, which can automatically generate test data packets according to the configuration file provided by the manufacturer; in the NAT type test, the program can automatically send and receive packets, analyze and compare to test the firewall NAT type; in the information leakage availability test, through an in-depth analysis of the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol, a test case is designed based on the vulnerability of the TCP / IP protocol, and a penetration test is performed on the firewall to detect whether the firewall can prevent information leakage in the intranet.
[0052] Furthermore, Virtual Private Dial Network (VPDN) technology is currently widely used by users in government, enterprises, and regulatory industries. Users use dedicated terminals with built-in dedicated Subscriber Identity Module (SIM) cards, configure dedicated access points (APNs), access the dedicated public data network (PDN) channels provided by operators, and access the enterprise's private network. Some office or business-related applications (APPs) are pre-installed on the terminals to communicate with the servers deployed by the enterprise in the private network.
[0053] Mobile office mode facilitates the operation of enterprises, but information security issues must be resolved.
[0054] For example, information security issues: on the one hand, it is necessary to restrict non-secure terminals from accessing the enterprise private network; on the other hand, it is also necessary to restrict the copying of internal data of secure terminals.
[0055] In order to protect the internal data of the secure mobile phone, some restrictions are also required on the mobile phone:
[0056] 1. Manage and control terminal peripherals such as Universal Serial Bus (USB) and Secure Digital Memory Card / SD card (SD) to prevent internal files from being copied out.
[0057] 2. Limit terminal devices from accessing the Internet to prevent terminal data from being transmitted through the network.
[0058] The embodiments of the present application mainly provide strict protection for scenarios where terminals access the Internet.
[0059] As mentioned above, private network terminals generally only pre-set private network APN information, but there are cases where they are connected to the Internet network.
[0060] For example: each region of an existing operator has a core network configuration. For example, an enterprise in region A applies for a private network permission for a certain APN in region A. Therefore, after inserting a SIM card with private network capability into the private network terminal, it will access the enterprise's private network. However, when the private network terminal inserts a SIM card of the same operator in region B, the terminal still uses the private network APN for dialing. When the request reaches region B, the core network will consider it an illegal APN and assign a data connection with Internet capability by default. In this way, the private network terminal is connected to the Internet network. This situation is very common. Of course, there are also cases where private network terminals mistakenly access the Internet network due to abnormal operator configuration.
[0061] At present, there is no comprehensive and unified approach in the industry to prevent private network terminals from accidentally accessing the Internet. Some private network terminals have not even taken any measures. The few methods that have been taken remain at the APP level, such as verifying the legitimacy of the SIM card, or checking whether the private network server is connected, and imposing some restrictions on the phone, such as forced screen lock.
[0062] The few existing measures to prevent access to the public network are strongly tied to the business, and the management and control apps of various projects cannot be unified, so it is not a solution that can be widely promoted. In addition, the current measures to prevent access to the public network are not perfect, and you can always try some special ways and violent methods to still access the Internet.
[0063] In view of the technical problems existing in the prior art, the inventor of the present application has the following idea: the data connection capability obtained by the terminal device depends entirely on the operator, and it is impossible to identify the scenario of mistakenly accessing the Internet from the signaling. If the detection mechanism is used in conjunction with the restrictions of the routing rules, the purpose of completely isolating the Internet network can be achieved, specifically: adding an Internet address detection mechanism, a detection packet can be sent to the Internet server, and the data connection can be disconnected after the packet is returned. During the detection process until the data connection is disconnected, the routing rules of the terminal can be changed to restrict the processes of non-root users and system users from accessing the Internet. After the data connection is disconnected, the routing rules are reset, and the restrictions on the processes of non-root users and system users are released, so that the terminal devices of the private network can always be isolated from the Internet network.
[0064] Figure 1 A schematic diagram of an application scenario of the network restriction method provided in an embodiment of the present application, such as Figure 1 As shown, the application scenario includes: a mobile phone 11 and a network server 12.
[0065] In one possible implementation, when a user illegally manipulates mobile phone 11 to access data on network server 12, mobile phone 11 monitors the attempted data connection request. At this time, mobile phone 11 executes the restriction on non-root user processes and system user processes to connect to the Internet network, and simulates sending packets to the preset network address. Based on whether a return packet is received, it is confirmed whether the current mobile phone 11 has the authority to access the network server 12. When a return packet is received within a certain period of time, it is considered that the access has the authority to access the Internet network, which is a violation and needs to be isolated, that is, the data connection is disconnected.
[0066] In this application scenario, the undisclosed contents are described in detail by the following embodiments.
[0067] It is worth noting that the application fields of the network restriction method, apparatus, terminal device and storage medium of the present application are not limited.
[0068] The execution subject of this application is the terminal device, which can be Figure 1 Mobile phones11, computers, smart watches, computers and other devices.
[0069] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0070] Figure 2 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 1 ,like Figure 2 As shown, the network restriction method may include the following steps:
[0071] Step 21: When it is detected that the terminal device is establishing a data connection with the Internet network, execute the first command.
[0072] The first command is used to restrict non-root user processes and non-system user processes from accessing the Internet network.
[0073] In this step, when it is detected that the terminal device is trying to establish a data connection with the Internet network, in order to prevent non-root users or non-system users, such as ordinary users, from accessing the Internet network, a command to restrict non-root user processes and non-system user processes from accessing the Internet network, i.e., the first command, needs to be executed.
[0074] Optionally, the first command is an iptables command.
[0075] The iptables command is used to set, maintain and check the Internet Protocol (IP) packet filtering rules of the Linux kernel. In other words, the iptables command can be used to filter non-root user processes and non-system user processes from accessing the Internet network.
[0076] Step 22: If it is detected that the data connection is established successfully, N threads are started to send simulation packets to the preset network addresses respectively.
[0077] Wherein, N is a positive integer.
[0078] In this step, after monitoring that the terminal device has established a data connection with the Internet network, in order to verify whether the current terminal device has the ability to access the Internet network, one or more threads can be started to send simulated packets to a pre-set network address for verification.
[0079] The simulation packet may be a preset data packet.
[0080] Optionally, the network address includes: an address corresponding to an Internet domain name, an Internet protocol version 4 (IPv4) address, and an Internet IPv6 address.
[0081] Then N is greater than or equal to 3.
[0082] In a possible implementation, the Internet domain name may be www.sina.com.cn, the Internet IPv4 address may be 110.242.68.66, and the Internet IPv6 address may be 2400:3200::1.
[0083] Correspondingly, this step may be implemented by starting at least three threads to send simulation packets to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address, respectively.
[0084] In a possible implementation, three threads are started, for example, thread A, thread B, and thread C. Thread A sends the first simulation packet to www.sina.com.cn; thread B sends the second simulation packet to 110.242.68.66; and thread C sends the third simulation packet to 2400:3200::1.
[0085] Optional, N is 9.
[0086] After some experiments, we found that when the number of threads is 9, the measured results are relatively optimal.
[0087] Step 23: If any thread receives a reply packet corresponding to the simulation packet within a preset time, the data connection is disconnected.
[0088] In this step, after at least one thread sends a simulation packet to a preset network address, it is monitored whether at least one thread receives a reply packet of the simulation packet within a preset time period.
[0089] Furthermore, if there is at least one thread that can receive a reply packet of the simulated packet, it means that the current terminal device has the ability to access the Internet network, and the data connection needs to be disconnected.
[0090] In a possible implementation, timing may be performed by using a timer. When N threads respectively send simulation packets to a preset network address, the timer is started, for example, the duration is set to 0.003s.
[0091] Exemplarily, Table 1 is an example table of thread-return packet situation 1 provided in an embodiment of the present application, as shown in Table 1 (taking the preset duration of 0.003s as an example):
[0092] Table 1
[0093]
[0094] That is, if within 0.003 seconds of monitoring, the threads that received the reply packets are thread A, thread B, and thread E, it means that the current terminal device has the ability to access the Internet network, and the data connection needs to be disconnected.
[0095] Furthermore, under the above implementation possibility, at 0.0015s, it is detected that thread B has received the reply packet, and the data connection is directly disconnected without waiting for other threads to receive the reply packet.
[0096] In addition, if any thread does not receive a reply packet corresponding to the simulation packet within a preset time, the data connection is maintained.
[0097] In this case, if there is no thread that does not receive a reply packet corresponding to the simulated packet within the preset time, it means that the current terminal device does not have the ability to access the Internet network, and there is no need to further process the data connection, and the data connection can be maintained.
[0098] Exemplarily, Table 2 is an example table of thread-return packet situation 2 provided in an embodiment of the present application, as shown in Table 2 (taking the preset duration of 0.003s as an example):
[0099] Table 2
[0100]
[0101] That is, if the above 9 threads do not receive a reply packet within 0.003s, it means that the current terminal device does not have the ability to access the Internet network and can maintain the data connection.
[0102] Furthermore, when the data connection is disconnected, or the time after the data connection is successfully established is longer than the preset time and no reply packet is received, the first reset command is executed to remove the restriction on non-root user processes and non-system user processes accessing the Internet network.
[0103] That is, in the two cases in the above embodiment:
[0104] Specifically, 1. If no reply packet is received from any thread within the preset time, the data connection is disconnected; 2. If no reply packet is received after the preset time (i.e., the timer expires).
[0105] It is necessary to reset the first command in the above step to restrict non-root user processes and non-system user processes from accessing the Internet network.
[0106] That is, issue a reset iptables command rule to remove the routing rule restrictions on non-root user processes and non-system user processes accessing the Internet network.
[0107] The network restriction method provided in the embodiment of the present application is applied to a terminal device. When it is detected that the terminal device is establishing a data connection with the Internet network, a first command is executed. The first command is used to restrict non-root user processes and non-system user processes from accessing the Internet network. After that, when it is detected that the data connection is successfully established, N threads are started to send simulation packets to the preset network address respectively, where N is a positive integer. Finally, if any thread receives a reply packet corresponding to the simulation packet within a preset time, the data connection is disconnected. In this technical solution, ordinary users accessing the Internet network are first restricted. After the data connection is successfully established, packets are simulated to multiple preset network addresses. If a reply packet is received within a certain period of time, it means that the data connection can access the Internet network, and then it is disconnected, thereby realizing a universal anti-Internet mechanism at the terminal level in a double insurance manner.
[0108] Based on the above embodiments, Figure 3 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 2 ,like Figure 3 As shown, the execution subject is a mobile phone, the network device can be a network server, and the typical process of the detection mechanism when connected to the Internet may include the following steps:
[0109] Step 31, the mobile phone attempts to activate the data connection to the network server;
[0110] Step 32: The mobile phone sends an iptables command to restrict non-root users and non-system users from accessing the routing rules of the network server;
[0111] Step 33: The network server returns data connection activation to the mobile phone;
[0112] Step 34, the mobile phone starts the timer;
[0113] Step 35, the mobile phone starts a thread to initiate a ping command;
[0114] The network address may be: www.sina.com.cn; 110.242.68.66; 2400:3200::1;
[0115] Step 36: The network server returns a response packet of any ping packet to the mobile phone before the timer expires;
[0116] Step 37, the mobile phone turns off the timer;
[0117] Step 38, the mobile phone disconnects the data connection with the network server;
[0118] After that, the data connection between the mobile phone and the network server was successfully disconnected;
[0119] Step 39: The mobile phone sends a reset iptables command to remove the routing rule restrictions on non-root user processes and non-system user processes accessing the network server.
[0120] The network restriction method provided by the embodiment of the present application is that the mobile phone tries to activate the data connection to the network server, the mobile phone issues an iptables command, restricts the process of non-root users and non-system users from accessing the routing rules of the network server, the network server returns the data connection activation to the mobile phone, the mobile phone starts the timer, and the mobile phone starts the thread to initiate the ping command, wherein the network address can be: www.sina.com.cn; 110.242.68.66; 2400:3200::1, the network server returns the reply packet of any ping packet to the mobile phone; the mobile phone turns off the timer, the mobile phone disconnects the data connection with the network server, and then the data connection between the mobile phone and the network server is successfully disconnected, and the mobile phone issues a reset iptables command to remove the routing rule restrictions on the process of non-root users and non-system users accessing the network server. In this technical solution, the premise of the dual-system security mobile phone is security, that is, restricting the work area from accessing the public network (network server), completely eliminating the situation where the work area accesses the public network, and using the detection mechanism in conjunction with the restriction of the routing rules to achieve complete isolation of the Internet.
[0121] Based on the above embodiments, Figure 4 Schematic diagram of the network restriction method provided in the embodiment of the present application Figure 3 ,like Figure 4 As shown, the execution subject is a mobile phone and the network device is a network server. The typical process of the detection mechanism when accessing a legitimate enterprise network may include the following steps:
[0122] Step 41, the mobile phone attempts to activate the data connection to the network server;
[0123] Step 42: The mobile phone sends an iptables command to restrict non-root users and non-system users from accessing the routing rules of the network server;
[0124] Step 43: The network server returns data connection activation to the mobile phone;
[0125] Step 44, the mobile phone starts the timer;
[0126] Step 45, the mobile phone starts a thread to initiate a ping command;
[0127] The network address can be: www.sina.com.cn, 110.242.68.66, 2400:3200::1;
[0128] Step 46: The network server does not receive any reply packet of the ping packet before the timer expires;
[0129] Step 47, the mobile phone turns off the timer;
[0130] Step 48: The mobile phone sends a reset iptables command to remove the routing rule restrictions on non-root user processes and non-system user processes accessing the network server.
[0131] The network restriction method provided by the embodiment of the present application is that the mobile phone tries to activate the data connection to the network server, the machine sends the iptables command, restricts the routing rules of non-root users and non-system users to access the network server, the network server returns the data connection activation to the mobile phone, the mobile phone starts the timer, and the mobile phone starts the thread to initiate the ping command, wherein the network address can be: www.sina.com.cn, 110.242.68.66, 2400:3200::1, the network server does not receive any ping packet before the timer ends, the mobile phone turns off the timer, and the mobile phone sends a reset iptables command to remove the routing rule restrictions on the process of non-root users and non-system users to access the network server. In this technical solution, after not receiving any ping packet, it means that the data connection does not have the function of accessing the Internet, that is, it can access the legal enterprise network and other permissions.
[0132] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the network restriction method of the present application. For details not disclosed in the embodiment of the network restriction device of the present application, please refer to the embodiment of the method of the present application.
[0133] Figure 5 This is a schematic diagram of the structure of the network restriction device embodiment provided in the present application. Figure 5 As shown, the network restriction device includes:
[0134] The processing module 51 is used to execute a first command when it is detected that the terminal device is establishing a data connection with the Internet network, and the first command is used to restrict the process of non-root users and non-system users from accessing the Internet network;
[0135] The starting module 52 is used to detect that the data connection is successfully established, and then start N threads to send simulation packets to the preset network address respectively, where N is a positive integer;
[0136] The disconnection module 53 is used to disconnect the data connection if any thread receives a reply packet corresponding to the simulation packet within a preset time period.
[0137] In a possible design of the embodiment of the present application, the processing module 51 is further used to:
[0138] If any thread does not receive a reply packet corresponding to the simulation packet within the preset time, the data connection is maintained.
[0139] In another possible design of the embodiment of the present application, the release module is used to:
[0140] When the data connection is disconnected, or the time after the data connection is successfully established is longer than the preset time and no response packet is received, the first reset command is executed to remove the restriction on non-root user processes and non-system user processes accessing the Internet network.
[0141] In another possible design of the embodiment of the present application, the network address includes: an address corresponding to an Internet domain name, an Internet IPv4 address, and an Internet IPv6 address;
[0142] Correspondingly, N is greater than or equal to 3.
[0143] Accordingly, the startup module 52 is specifically used for:
[0144] Start at least three threads to send simulated packets to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address respectively.
[0145] In another possible design of the embodiment of the present application, N is 9.
[0146] In another possible design of the embodiment of the present application, the first command is an iptables command.
[0147] The network restriction device provided in the embodiment of the present application can be used to execute the network restriction method in any of the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0148] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0149] Figure 6 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application, such as Figure 6 As shown, the terminal device may include: a processor 61, a memory 62, and computer program instructions stored in the memory 62 and executable on the processor 61, and the processor 61 implements the method provided in any of the foregoing embodiments when executing the computer program instructions.
[0150] Optionally, the above-mentioned components of the terminal device may be connected via a system bus.
[0151] The memory 62 may be a separate storage unit or a storage unit integrated in the processor 61. The number of the processor 61 is one or more.
[0152] It should be understood that the processor 61 can be a central processing unit (CPU), or other general-purpose processors 61, digital signal processors 61 (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor 61 can be a microprocessor 61 or the processor 61 can also be any conventional processor 61, etc. The steps of the method disclosed in the present application can be directly embodied as being executed by the hardware processor 61, or can be executed by a combination of hardware and software modules in the processor 61.
[0153] The system bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The memory 62 may include a random access memory 62 (RAM), and may also include a non-volatile memory 62 (NVM), such as at least one disk memory 62.
[0154] All or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions. The above-mentioned program can be stored in a readable memory 62. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the above-mentioned memory 62 (storage medium) includes: read-only memory 62 (ROM), RAM, flash memory 62, hard disk, solid state hard disk, magnetic tape, floppy disk, optical disc and any combination thereof.
[0155] The terminal device provided in the embodiment of the present application can be used to execute the network restriction method provided in any of the above method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0156] An embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the above-mentioned network restriction method.
[0157] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory, electrically erasable programmable read-only memory, erasable programmable read-only memory, programmable read-only memory, read-only memory, magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0158] Optionally, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0159] An embodiment of the present application also provides a computer program product, which includes a computer program. The computer program is stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When the at least one processor executes the computer program, the above method can be implemented.
[0160] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A network restriction method, characterized in that: Applied to a terminal device, the method comprises: When it is detected that the terminal device is establishing a data connection with the Internet network, a first command is executed, wherein the first command is used to restrict non-root user processes and non-system user processes from accessing the Internet network; When it is detected that the data connection is successfully established, N threads are started to send simulation packets to the preset network addresses respectively, where N is a positive integer; If any of the threads receives a reply packet corresponding to the simulation packet within a preset time period, the data connection is disconnected.
2. The method according to claim 1, characterized in that The method further comprises: If any of the threads does not receive a reply packet corresponding to the simulation packet within the preset time period, the data connection is maintained.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: When the data connection is disconnected, or the time after the data connection is successfully established is greater than the preset time and the return packet is not received, the first command is reset to lift the restriction on the non-root user's process and the non-system user's process accessing the Internet network.
4. The method according to claim 1 or 2, characterized in that: The network address includes: an address corresponding to an Internet domain name, an Internet protocol version ipv4 address, and an Internet ipv6 address; Accordingly, N is greater than or equal to 3; Correspondingly, the starting of N threads to send simulation packets to preset network addresses respectively includes: At least three threads are started to send the simulation packet to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address respectively.
5. The method according to claim 1 or 2, characterized in that: The N is 9.
6. The method according to claim 1 or 2, characterized in that: The first command is an iptables command.
7. A network restriction device, characterized in that: Applied to a terminal device, the device comprises: A processing module, configured to execute a first command when detecting that the terminal device is establishing a data connection with the Internet network, wherein the first command is configured to restrict non-root user processes and non-system user processes from accessing the Internet network; A startup module, configured to start N threads to send simulation packets to a preset network address respectively upon detecting that the data connection is successfully established, wherein N is a positive integer; The disconnection module is used to disconnect the data connection if any of the threads receives a reply packet corresponding to the simulation packet within a preset time period.
8. The device according to claim 7, characterized in that The processing module is further used for: If any of the threads does not receive a reply packet corresponding to the simulation packet within the preset time period, the data connection is maintained.
9. The device according to claim 7 or 8, characterized in that Deactivate module for: When the data connection is disconnected, or the time after the data connection is successfully established is greater than the preset time and the return packet is not received, the first command is reset to lift the restriction on the non-root user's process and the non-system user's process accessing the Internet network.
10. The device according to claim 7 or 8, characterized in that The network address includes: an address corresponding to an Internet domain name, an Internet IPv4 address, and an Internet IPv6 address; Accordingly, N is greater than or equal to 3; Accordingly, the startup module is specifically used for: At least three threads are started to send the simulation packet to the address corresponding to the Internet domain name, the Internet IPv4 address, and the Internet IPv6 address respectively.
11. The device according to claim 7 or 8, characterized in that The N is 9.
12. The device according to claim 7 or 8, characterized in that The first command is an iptables command.
13. A terminal device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Alarm and blocking method for illegal external connections
CN103391216A
Mobile terminal preset networking address firewall isolation application system
CN103973700A
Method and device for quickly detecting terminal sharing access
CN107948199A
Detecting method for illegal external connection of inner net computer
CN1750480A
System and method for limiting public network access user number on basis of linux by cpe
WO2016034122A1
