Telnet unlocks on Xiaomi Gateway 3: a complete guide with commands and warnings

The Xiaomi Gateway 3 is the central device of the Mi Home ecosystem, but its standard settings often limit the capabilities of advanced users. Activation of the Telnet protocol allows you to gain low-level access to the system, change configurations, integrate devices with alternative platforms (for example, Home Assistant), or fix software failures. However, the unlocking process requires caution: improper actions can lead to a loss of warranty or β€œbricking” of the device.

In this article, you will find current methods for opening Telnet for Gateway 3 (model lumi.gateway.mgl03), including alternative methods for closed-port firmware. We will discuss the necessary tools, step-by-step commands, and typical errors and their solutions. If you are new to network protocols, we recommend that you first familiarize yourself with the basic principles of SSH/Telnet and configuration backup.

Why Telnet on Xiaomi Gateway 3 is blocked by default

Xiaomi is deliberately cutting off Telnet access for the security and control of the ecosystem, and these are the key reasons:

  • πŸ”’ Protection against unauthorized access: Open port 23 can be a target for botnet attacks (e.g. Mirai).
  • πŸ“¦ Xiaomi aims to keep users in its ecosystem by limiting integration with third-party systems.
  • πŸ› οΈ Stability: Changing system files can disrupt gateway and connected devices.
  • πŸ“„ License Restrictions: Some software components have proprietary licenses that prohibit modifications.

But enthusiasts find workarounds, like in the firmware before the version. 1.5.6_0046 Telnet could be activated via miio protocol, but newer versions require more complex manipulations, including firmware or exploiting vulnerabilities.

πŸ“Š Why you need Telnet on Xiaomi Gateway 3?
Integration with Home Assistant
Device debugging
Installation of custom software
Curiosity
Other

Preparation for Unlocking: Tools and Requirements

Before starting the procedure, make sure you have:

  • πŸ–₯️ Windows computer 10/11, macOS or Linux (Ubuntu recommended) 22.04+).
  • πŸ”Œ Xiaomi Gateway Gateway 3 firmware 1.5.6_0046 or below (check in Mi Home) β†’ Gateway settings β†’ About the device).
  • πŸ“‘ Stable connection to a single network (Wi-Fi or Ethernet) for gateway and PC.
  • πŸ› οΈ Utility: Telnet client (built into Windows, for Linux/macOS β€” telnet from the terminal. Python 3.8+ with python-miio library (pip install python-miio) Fiddler or Charles Proxy for traffic interception (optional).

⚠️ Note: If your gateway is running on firmware newer 1.5.6_0046, Miio protocol will not work, and this will require a downgrade of firmware or the use of alternative exploits (see "Methods for new firmware" section").

β˜‘οΈ Pre-testing

Done: 0 / 4

Method 1: Activation of Telnet via miio protocol (firmware to the 1.5.6_0046)

This method works for most devices purchased before 2022.The algorithm is based on sending special commands through the MiIO protocol, which is used to control Xiaomi devices.

Steps:

  1. Get a gateway token: Download the Mi Home Token Extractor (Android) app. Log in to your Mi Home account and find the gateway in the device list. Copy Token (32-digit hex key).

Connect to the gateway through Python

from miio import ChuangmiPlug


ip = "192.168.x.x" # IP- gateway address




token = "YOUR_TOKEN_HERE" # Your token




gateway = ChuangmiPlug(ip, token)




gateway.send("miIO.open_telnet")

If the command is successful, the Telnet server is activated on port 23.

Connect to Telnet.

telnet 192.168.x.x

Default Login/Password: root/empty password.

⚠️ Warning: After the gateway is restarted, Telnet may shut down again. To make the changes permanent, you need to edit the file. /etc/init.d/rcS (see next section).

πŸ’‘

If the team miIO.open_telnet It doesn’t work, try an alternative: set_telnet 1 via the same protocol.

Method 2: Change the rcS to make permanent access

To keep Telnet active after the reboot, you need to modify the autorun script, which requires open Telnet access (see Method 1).

Instructions:

  1. Connect to the gateway via Telnet: telnet 192.168.x.x
  2. Edit the rcS file: vi /etc/init.d/rcS Add a line before exit 0: telnetd -l /bin/sh -p 23
  3. Save the changes (:wq in vi) and reboot the gateway: reboot

After restarting, check the availability of Telnet. If the connection is not restored, make sure that:

  • The rcS file has execution rights (chmod +x /etc/init.d/rcS).
  • There is enough free memory in the system (check with df-h).
What should I do if I am not installed?
If the system does not have a vi editor, use echo to add the line: echo "telnetd -l /bin/sh -p 23" >> /etc/init.d/rcS But this method is less reliable, as it can duplicate lines.

Ways for new firmware (1.5.6_0046 higher)

In the updated versions, Xiaomi has closed the vulnerability with miIO.open_telnet. Alternative methods:

MethodDifficultyTools requiredRisks.
Exploitation through UDP-packetMediumPython, ScapyPossible lockdown MAC-address
Downgrade firmwareTall.Mi Home, backupData loss, brick risk
Substitution of certificatesTall.Fiddler, OpenSSLMi Home malfunction
Hardware method (UART)ExpertSolding iron, USB-TTL adapterLoss of warranty, damage to fees

The most reliable way for beginners is downgrade firmware:

  1. Download the old firmware (for example, 1.5.6_0046) repository.
  2. In Mi Home, go to Gateway Settings β†’ Software Update β†’ Local File.
  3. Download the downloaded file and wait for the process to be completed.

⚠️ Warning: Downgrad can cause loss of tethered devices.Untie all sensors and sensors in Mi Home before the procedure!

Common mistakes and their solutions

When unlocking Telnet, users often face the following problems:

  • 🚫 Connection refused error: Check that the port 23 not blocked by firewall (netstat) -tuln | grep 23). Make sure the gateway doesn't overheat (reset it).
  • πŸ”„ Telnet shuts down after restart: Check the rights to the rcS file (ls) -la /etc/init.d/rcS). Use cron to automatically start: echo " *telnetd" -l /bin/sh -p 23" >> /etc/crontabs/root
  • πŸ”‘ Token is not suitable: Make sure you copy the token specifically for the gateway and not for another device.Regenerate the token via Mi Home Token Extractor.

If the gateway stopped responding after manipulation, try resetting it to factory settings: press the reset button for 10 seconds before the yellow LED blinks.

πŸ’‘

Before any changes to system files, back them up with the command cp /etc/init.d/rcS /etc/init.d/rcS.bak.

Security after unlocking Telnet

An open Telnet port is a potential security threat to minimize the risks:

  • πŸ” Change the root password: passwd root Use a complex password (at least 12 characters with numbers and special characters).
  • 🌐 Restrict access by IP: iptables -A INPUT -p tcp --dport 23 -s 192.168.x.0/24 -j ACCEPT iptables -A INPUT -p tcp --dport 23 -j DROP Replace. 192.168.x.0/24 subnet.
  • πŸ”„ Disable Telnet after use: Killall telnetd or delete a string from rcS if access is no longer needed.
  • πŸ“‘ Use it. VPN Remote access instead of port port port transfer on the router.

⚠️ Note: If the gateway is connected to a public network (such as an office or hotel), never open Telnet without the need to open it. VPN. Attackers can scan ports and gain control of your smart home system.

FAQ: Frequent questions about Telnet on Xiaomi Gateway 3

Can I open Telnet without a token?
Yes, but only for old firmware (until now). 1.4.1_0035) vulnerability UDP 4321. To do this, send a special package using Scapy: from scapy.all import * send(IP(dst="192.168.x.x")/UDP(dport=4321)/"\x21\x35\x01\x00\x00\x00") However, this method is unstable and may not work the first time.
How to return the gateway to factory settings if it does not turn on?
If the gateway is bricked after the changes, try the hardware reset: Turn off the gateway power. Press the reset button (the hole next to the power connector). Connect the power, holding the button 15-20 seconds until the orange LED blinks. Release the button and wait for the reboot (up to 5 minutes). If this does not help, you will need to reflash through UART.
Can I open Telnet on Gateway 3 with Home Assistant?
No, Home Assistant doesn't provide any tools to unlock Telnet. However, once Telnet is activated, you can integrate the gateway into the Telnet. HA via the Xiaomi Gateway component 3 Extended settings. Example configuration: xiaomi_aqara: gateways: - key: YOUR_KEY_HERE mac:!secret gateway_mac host: 192.168.x.x port: 9898
What are the best commands after connecting to Telnet?
Here are the basic commands for diagnosis and configuration: uname -a is the kernel version. df -h is free disk space. ps is a list of running processes. iwconfig is the Wi-Fi state. cat /proc/cpuinfo is information about the processor. nvram show is system variables (including Wi-Fi passwords!). Attention: nvram command displays sensitive data - do not publish its output in public sources.
Is this legal from Xiaomi’s point of view?
No, unlocking Telnet violates Xiaomi's user agreement. The company can: Denie warranty service, block Mi Home account if it detects modifications, disconnect your device from cloud services, but in practice, lockdowns are rare unless you distribute modified software.