OpenWrt ​has a built-in failsafe mode which will attempt to bypass almost ​all configuration in favor of a few hard coded defaults, resulting in a router ​that boots up as ''​192.168.1.1/​24''​ with only essential services running. ​From this state you can ''​telnet''​ in and fix certain problems.

+

OpenWrt ​SquashFS-Images have a built-in failsafe mode. OpenWrt failsafe mode bypasses ​all configuration ​located on the JFFS2 partition (that is the writable partition), ​in favor of a few hard coded defaults ​located on the SquashFS partition (that is the read-only partition), resulting in a device ​that boots up as **''​192.168.1.1/​24''​** on the **''​eth0''​** network interface ​with only essential services running. ​(In case your device has multiple network interfaces (eth0, eth1, ...), usually eth0 is the interface connected to the [[doc:​hardware:​switch]]. There may be very seldom exceptions.)

-

Reading [[doc:​techref:​Flash Layout]], ​you should understand, that the OpenWrt failsafe can help you with any problems ​referring to the [[doc:​techref:​filesystem#JFFS2]] partition if you have a [[doc:techref:​filesystems#​SquashFS|SquashFS]] image installed! In case you forgot your password or you firewall-ed yourself or you broke one of the startup scripts, you can get back in by using OpenWrt'​s ​failsafe mode.

+

From this state you can **''​telnet''​** in, mount the JFFS2 partition ​with the command ''​mount_root''​ and fix problems ​located on the JFFS2 partition, e.g. forgotten password, bad firewall settings, broken startup scripts, etc. Please read **[[doc:​techref:​flash.layout#partitioning.of.squashfs-images|OpenWrt Flash Layout]]** to understand why OpenWrt failsafe is possible, and also [[doc/techref/​process.boot|Boot Process]] to understand how it works: basically OpenWrt contains an additional boot up stage, called preinit. This allows ​OpenWrt ​to boot into normal mode by default or boot into failsafe mode, if this was triggered by the user. The triggering can happen in two ways: via pressing ​a hardware button during preinit-stage or via keyboard command while connected over a serial ​cable to the PCB during preinit-stage. No matter how the booting into failsafe mode was triggered, once OpenWrt boots into failsafe mode, you can telnet in over Ethernet.

-

+

-

Alternatively you require ​a possibility to connect to the console ​via the serial ​interface on the PCB.

+

+

**→ [[doc:​howto:​generic.debrick]]**

===== Prerequisites =====

===== Prerequisites =====

-

* <color red>your device must have a **configurable hardware button**</​color>,​ if there'​s a button on your router, it's likely to be configurable. Check if there'​s specific info about failsafe mode for your [[toh:|box]] and make sure everything still works as expected everytime you update!

+

* <color red>your device must have a **configurable hardware button**</​color>,​ if there'​s a button on your router, it's likely to be configurable. Check if there'​s specific info about failsafe mode for your [[toh:|device]] and make sure everything still works as expected everytime you update!

-

* everything but the [[doc:​techref:​filesystems#​JFFS2]] partition, i.e. the kernel and the [[doc:​techref:​filesystems#​SquashFS|SquashFS]] partition, must be intact, so that...

+

* there must be a **SquashFS-Image** flashed to the device. Failsafe cannot be implemented on JFFS2-Images

+

* everything but the [[doc:​techref:​filesystems#​JFFS2]] partition, i.e. the kernel ​partition ​and the [[doc:​techref:​filesystems#​SquashFS|SquashFS]] partition, must be intact, so that...

* ...the boot process is able to get as far as required to register the pressing of the button

* ...the boot process is able to get as far as required to register the pressing of the button

* ...the minimal required binaries and the configuration files with some default settings are available (all on SquashFS)

* ...the minimal required binaries and the configuration files with some default settings are available (all on SquashFS)

-

-

<​HTML>​

-

<p style="​border:​2px dashed green;​text-align:​center">​

-

<span style="​color:​green;​font-size:​80%;"><​b>​You should save this page for offline viewing before you find yourself without internet connection.</​b></​span>​

-

</p>

-

<p style="​border:​2px dashed red;​text-align:​center">​

-

<span style="​color:​red;​font-size:​80%;"><​b>​Warning:​ Do not start Failsafe while the router is connected to any untrusted network. The switch could be automatically configured to forward packages between all ports including the WAN port in failsafe mode. Traffic could travel between the WAN and the LAN bypassing the router'​s firewall.</​b></​span>​

* If you do not receive ​this message try immediately after the turning ​the router ​on, rapidly ​click and keep clicking ​the button ​on the router for about 60 seconds.

+

* Unplug the WAN port (in case that WAN IP address and LAN IP address are same (address collision happened), if you do not plug out wan port, you cannot enter failsafe mode)

-

* It may be any button, ​but if you can't get in failsafe mode with a button try another.

+

-

* If done right, the ''​192.168.1.1''​ address will be pingable, and telnettable.

+

==== Stage 1: Computer IP settings ====

-

* //​Note: ​If your router has a ridiculously long boot time (such as [[toh/​d-link/​dir-300#​with.manual.step.by.step.guide|DIR-300 A]]), then you may do this for a longer time.//

+

-

- Telnet into ''​192.168.1.1''​ where you will get immediate access to root shell/​prompt. Authentication won't be required.

+

* Set your computer'​s IP to ''​192.168.1.2'',​ subnet ​mask ''​255.255.255.0''​. The router will be reached at ''​192.168.1.1''​ when failsafe mode is running. (You may use any IP in the range ''​192.168.1.2-254''​.)

-

* It could be that the router listens just on one Ethernet port, this is the caste at least for brcm47xx before Attitude Adjustment Beta2, also try the WAN port.

+

-

- Try out the commands [[doc:​howto:​generic.failsafe#​in.failsafe.mode|below]].

+

==== Stage 2: Detect when failsafe mode can be triggered ====

+

+

​* To detect when failsafe mode can be triggered, there are two options: look for a bootup LED blink pattern, or look for a special broadcast packet from the router

On many routers, OpenWrt will start to blink a "​SYS"​ LED (may be "Power", may be other) on the front of the router when it is in its early boot cycle. The blink rate is about twice a second. Looking for a blink pattern is much more convenient to use instead of having to use a packet sniffer.

+

+

* Power on the router.

+

* As soon as this blink pattern is seen, press the any hardware button of the router.

+

* The LED will change to faster blink pattern, indicating the router is now in failsafe mode.

+

+

Some routers has the button only on the back of the unit (often labeled "​Reset"​ or "​WPS/​Reset"​). The switch may have a visible (external) button, or may be behind a hole (with button in the depth). In this case and require a paper clip or similar tool to operate. Please no not use the nail when press the button in the hole.

+

+

At least [[toh:tp-link:​tl-wdr4300#​failsafe.mode|one TP-Link router]] seems to respond better to repeatedly clicking the button //before //the SYS LED starts to blink, until the SYS LED lights with the rapid-flash pattern.

Up to today (Jan 11, 2013) this page didn't precise on which port to listen. ​In the case of TL-WR1043ND,​ it's the WAN port. ​If you find a contradictory example, it will be necessarry to <a href="?​do=edit">​remove or adapt </​a> ​this note.

Power-cycle ​the router. The router will deliver a message telling it waits for your click on the button.

+

+

== Message under Linux (only the firt part)==

+

Run ''​wireshark'',​ ''​cshark''​ or ''​tcpdump''​\\

+

{{:​doc:​howto:​linux-failsafe.png|}}

+

+

== Message under Windows (only the first line)==

+

Monitor the special packet in a program ''​recvudp.exe''​.\\

+

{{:​media:​failsafe2.png|}}

+

+

== Note ==

+

Not all versions of OpenWRT sends the "​success"​ packet.

+

+

==== Stage 3: Trigger a failsafe boot using a button ​====

+

+

Immediately when the LED blink pattern or the network broadcast message is seen, click the device button. If your device has multiple buttons, any button should work. OpenWrt is configured ​in a way, that pressing of any button during preinit will trigger booting into failsafe mode. But in case a button ​should not work, try another.

+

+

==== Stage 4: Log into the router using failsafe ====

+

+

Indications of failsafe mode:

+

​* Once in failsafe mode, a network broadcast confirmation message appears (not always, for the TL-WR1043ND no message comes).

+

* On some router models (e.g. TP-LINK models), the SYS led blinks very quickly

+

+

Now, **telnet** (//not// SSH) to 192.168.1.1 ​from the computer. There is no username or password required.

+

+

Now go to section [[#In failsafe mode]]

+

+

==== Remarks ====

+

+

* If the router does not boot in safe mode despite clicking the button, it may be a timing problem, missing the brief window when OpenWrt is looking for a button press. If so, immediately after turning the router on, rapidly click and keep clicking the button on the router for about 60 seconds to try to not miss the safe mode boot window.

+

* If your router has a ridiculously long boot time (such as [[toh/​d-link/​dir-300#​with.manual.step.by.step.guide|DIR-300 A]]), then you may do this for a longer time. ​

**NOTE:** The root file system in failsafe mode is the only the [[doc:​techref:​flash.layout|SquashFS]] partition. The JFFS2 is not present. To mount JFFS2 in read-write mode run ''​[[https://​dev.openwrt.org/​browser/​trunk/​package/​base-files/​files/​sbin/​mount_root|mount_root]]'':​

**NOTE:** The root file system in failsafe mode is the only the [[doc:​techref:​flash.layout|SquashFS]] partition. The JFFS2 is not present. To mount JFFS2 in read-write mode run ''​[[https://​dev.openwrt.org/​browser/​trunk/​package/​base-files/​files/​sbin/​mount_root|mount_root]]'':​

Line 79:

Line 173:

* In case you forgot your password, you need to set a new one. Type:<​code>​passwd</​code>​

* In case you forgot your password, you need to set a new one. Type:<​code>​passwd</​code>​

* In case you forgot the routers IP address, get it with<​code>​uci get network.lan.ipaddr</​code>​

* In case you forgot the routers IP address, get it with<​code>​uci get network.lan.ipaddr</​code>​

-

* In case you filled up the entire JFFS2 by installing too big/too many packages, clean the entire JFFS2 partition. All settings will be reset and all installed packages are removed. (OpenWrt equivalent of a factory reset)<​code>​firstboot</​code>​ or <​code>​mtd -r erase rootfs_data</​code>​ or <​code>​rm -r /​overlay/​*</​code>​

+

* In case you filled up the entire JFFS2 by installing too big/too many packages, clean the entire JFFS2 partition. All settings will be reset and all installed packages are removed. (OpenWrt equivalent of a factory reset)<​code>​firstboot</​code>​ or (this will reboot the device as part of the process) ​<​code>​mtd -r erase rootfs_data</​code>​ or <​code>​rm -r /​overlay/​*</​code>​

If you are done with failsafe mode use <​code>​reboot -f</​code>​ to reboot. //Note: Normal ''/​sbin/​reboot''​ will not work, because ''​init''​ is not running.// Or power cycle the router.

If you are done with failsafe mode use <​code>​reboot -f</​code>​ to reboot. //Note: Normal ''/​sbin/​reboot''​ will not work, because ''​init''​ is not running.// Or power cycle the router.