Child's Phone Anti-Addiction - Router Scheduled Network Disconnection
Learn how to promptly schedule a network disconnection for a child’s phone (set-top box, iPad, electronic learning devices, and other similar devices).
Enable control from another smartphone with just 1-2 buttons to schedule automatic network disconnection for a child’s phone (electronic device anti-addiction).
What’s the Use
Enable the phone with scheduled network disconnection using just 1-2 buttons from another smartphone.
Advantages: Single-button operation without the need for subsequent actions; no need to touch the child’s phone. Since, under normal circumstances, the Wi-Fi and data networks of the phone are concurrently open, in this disconnection, the Wi-Fi connection remains intact (only the router discards the internet’s data packets). The phone continues to automatically send data to the Wi-Fi (router), yet it doesn’t receive the return data packets.
Disadvantages: Deployment requires some computer knowledge, and the steps are a bit cumbersome.
Background and Personal Application
Indeed, we have a “poop incentive” mechanism, where using the restroom allows for phone use.
“Don’t laugh, this method is extremely effective, much more effective than modern hospital medical treatments for conditions caused by delayed bowel movements.”
“We discovered that guidance with children is still primarily at the mental level and is quite critical and urgent.”
However, the problem arises when children, enticed by prolonged phone use, spend an extended period (over half an hour) in the restroom. While it serves the purpose of using the restroom, it also comes with side effects. After several attempts with verbal reminders, the desired impact wasn’t achieved, causing frustration and tense atmospheres.
Suddenly, the idea emerged that iPads use the OP’s iptables command to discard data packets (restricting external internet access). So why not automatically remind children to end “restroom” time by timely or scheduled limitations on their device’s internet access? How convenient would it be for parents to quickly schedule the closure of network access and then automatically restore the device’s internet access 10 minutes later? This functionality could be easily achieved using shell or python.
For areas where assistance is needed, don’t hesitate to inquire online at ChatGPT.
How to Use
Current prerequisite conditions: Your home router needs to be able to install Python (this requirement is relatively high).
One could modify the script to a shell version. This way, even low-cost routers such as the K2P or similar (with a flashed system) could support it.
- When the child needs to use the electronic device, inform them in advance: they can only use it for 15 minutes (the specific time can be adjusted according to individual circumstances). After the time is up, the device will automatically disconnect from the network.
- After obtaining their consent, unlock the phone (or set-top box, etc.) for the child to use.
- Open the parent’s phone, log in to ConnectBot (or any other SSH tool on Android or iOS), and simply run the Python command.
- With one command, the parent doesn’t need to take any further action. The program will automatically disconnect the specific electronic device from the network at the designated time and then restore it after a certain period (at which point, the phone is already locked).
Related Content
If you are interested in OpenWrt or related content, the following information may be helpful for you:
Implementation Method
Below is an example using routers with an OpenWrt system (hosting a Python environment) and an Android phone:
The following two aspects are needed; no other settings are required, and no apps need to be installed.
Setting Up the Router Side
Log into the router’s SSH from a computer or phone,
1 | cd /root |
How to Find the MAC Address of Devices such as Phones
Open the OpenWrt web interface and check the connected devices.
Here is my personal URL for checking.
Setting Up the Controlling Smartphone
(Example using an Android phone)
- Download and install the open-source SSH client: ConnectBot.
- Download link: download ConnectBot from our releases page https://github.com/connectbot/connectbot/releases/
- (One-time setup) Generate a key using ConnectBot.
- Select the top right corner (three dots).
- Manage Keys.
- Top right corner (plus sign).
- Enter a key name (for self-identification).
- Default RSA type.
- 1024 bits is sufficient.
- Password: can be left empty for use within a home LAN.
- Generate.
- Follow the guide: randomly swipe the screen until the key is fully generated (100% progress).
- Top right corner (three dots) “Copy Public Key” (use it later in step three for pasting).
- (One-time setup) Set up a new host connection.
- Plus sign at the bottom right.
- Enter (with SSH enabled): username@router’s IP address, e.g., root@192.168.123.1.
- Click “Use Authentication Key.”
- Choose the previously saved key.
- “Post-login automation”
- Write: python /root/laShiPhone.py.
- Save
Returning to the Router Settings for Passwordless Login
Refer to Passwordless Login to OpenWrt via SSH
- SSH into the router and either create or edit (/if already exists authorized_keys file)
- Paste the content from the step 2 (Setup Controlling Smartphone > Operation ConnectBot Generate Key > Copy Public Key).
- Save authorized_keys. After copying is complete, log in normally once to the target host.
- After logout, log in once more. At this point, the SSH key should automatically log into the target host (without needing to enter a password).
Practice Operational
- Open the controlling smartphone.
- Tap the saved hostname (it will log in automatically).
- Press Enter to start the one-click process (the command set in “Post-login automation” will run automatically after login).
Other Situations
You might say, “What if my router doesn’t have a Python environment, and it’s one of those simple OpenWrt systems?”
In that case, you can inquire from ChatGPT and convert the script to a shell version. The only difference will be to execute using chmod and then run: . /XXX.sh. If you need more instructions, I can convert it into a shell version.
Inspiration Sources
iPad Activation Lock Bypass Experience
Circumventing a Roundabout Process
【Optional Step】For safety reasons, to create a new user on OpenWrt:
SSH into the router
vim to open the passwd file, command: vim /etc/passwd
Insert at the end: (enter i in vim to enable editing)
Username:*:UserID:GroupID:Three commas:/home/username:/bin/bash
Example: user123:*:1000:1000:,,,:/home/user123:/bin/bash
Be sure to use all English, and it’s recommended that the ID be above 1000, not below 100. Check for accuracy and save (press esc to exit editing, then :wq to save and exit).
Then edit the group file, command: vim /etc/group
Similarly, insert at the end:
Groupname:*:GroupID:
Example: user123:*:1000:
I found some downsides of Termius,
it has many limitations, after all, it’s a paid software
Switching back to ConnectBot, I realized that passwordless login was just as easy and even more secure.
Improvement
Upon accessing ConnectBot on the mobile device, configured for automatic router login and preset default commands, the process becomes quite convenient. It enables selective temporary disabling of specific electronic devices’ internet access via maintaining different clients.
However, upon discovering that once the mobile device exits ConnectBot, the command ceases to execute—regardless of whether it was in the midst of a 15-minute wait period or just idling.
Enabling Python Program to Run in the Background
Utilize “nohup” (no hand up). By prefixing a command with “nohup,” the program will execute in the background. Subsequently, we can review “nohup.out” afterwards to glimpse certain information or use “ps” to verify whether the command “python /root/laShiPhone.py” exists (it disappears after approximately 30 minutes).
The default execution has transformed to: “nohup python /root/laShiPhone.py”
Next Steps
Currently seeking a solution, contemplating:
Embedding an anti-addiction system into the mobile device
Xiaomi K40
Android screen time management application
Mobile device’s adolescent mode
Child space feature
Having attempted to install the child space feature from Oppo on my OnePlus device, an error message appeared: “Unable to parse package.”
Returning to the original solution, given the device is already rooted, directly deleting system’s pre-installed browser, app store, and other default applications.
Removing the App Store
Within /system/app, I located OnePlus’ modified system pre-installed browser derived from Tencent’s. It was removed.
Unable to locate “App Store,” the solution lay in leveraging the adb tool:
- Connect OnePlus 5T to the computer
- Manage apps using adb (Android system package):
1 | .ssh % adb -s 5d817fad shell pm list packages | grep market |
Later, it was discovered that some applications were installed in: /system/reserve.
This “pm uninstall” command works universally on all Android devices and can be utilized on any Android system.
This section is indebted to: