Differences

This shows you the differences between two versions of the page.

doc:howto:generic.failsafe [2013/01/06 21:14]
eugenius
doc:howto:generic.failsafe [2013/06/07 10:49] (current)
lorema
Line 1: Line 1:
====== OpenWrt Failsafe ====== ====== OpenWrt Failsafe ======
-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 router that boots up as **''192.168.1.1/24''** with only essential services running.
-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 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 booted 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.+
===== 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:|box]] 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>
 +<table class="inline" style="width:70%; margin-left:15%">
 +  <tr>
 +    <td style="border-left:6px solid #f57900; vertical-align:middle">
 +      <img src="/_media/meta/icons/tango/48px-emblem-important.svg.png" alt="" style="float:left; margin-right:0.5em" />
 +      <strong>Important Information!</strong><br />
 +      You should save this page for offline viewing before you find yourself without internet connection.
 +    </td>
 +  </tr>
 +</table>
 +</html>
 +
 +<html>
 +<table class="inline" style="width:70%; margin-left:15%">
 +  <tr>
 +    <td style="border-left:6px solid #cd0505; vertical-align:middle">
 +      <img src="/_media/meta/icons/tango/48px-dialog-warning.svg.png" alt="" style="float:left; margin-right:0.5em" />
 +      <strong>Warning !</strong><br />
 +      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.
 +    </td>
 +  </tr>
 +</table>
 +</html>
-<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> 
-</p> 
-</HTML> 
===== Triggering via Hardware Button (Standard OpenWrt method) ===== ===== Triggering via Hardware Button (Standard OpenWrt method) =====
-  - Set your computer's IP to ''192.168.1.2'', subnet ''255.255.255.0'' + 
- - Power cycle the router (turn off and turn on) +==== Stage 0 ==== 
- - Listen on UDP port 4919 for a broadcast packages on your computer, the router will send a message when it waits for a button click+Plug out wan port. 
-   * <wrap>On Linux run ''tcpdump -Ani eth0 port 4919 and udp'' to listen for that message. \\ +(In case that wan ip address and lan ip address are same(address collision happend), if you do not plug out wan port, you cannot enter failsafe mode) 
-{{:doc:howto:linux-failsafe.png|}} \\ + 
-\\ + 
-</wrap+==== Stage 1 ====  
-    * <wrap>On Windows the ''[[http://downloads.openwrt.org/people/florian/recvudp/recvudp-win32.zip|recvudp.exe]]'' utility can be used - launch it before powering on the router and wait for the failsafe message to appear. \\ +Set your computer's IP to ''192.168.1.2'', subnet ''255.255.255.0'' 
-{{:doc:howto:win32-failsafe.png|}} \\ +==== Stage 2 ==== 
-\\ +Listen on the  UDP 4919 port for a broadcast packet on the computer.  
-</wrap> +=== Under Linux === 
-   * 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.  + 
-     * It may be any button, but if you can't get in failsafe mode with a button try another. +In a terminal enter the command  <code>tcpdump -Ani eth0 port 4919 and udp</code> 
-     * If done right, the ''192.168.1.1'' address will be pingable, and telnettable. +<html> 
-      * //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.// +<table class="inline" style="width:70%; margin-left:15%"> 
-  - Telnet into ''192.168.1.1'' where you will get immediate access to root shell/prompt. Authentication won't be required. +  <tr> 
-     * 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+    <td style="border-left:6px solid #f57900; vertical-align:middle"> 
-  - Try out the commands [[doc:howto:generic.failsafe#in.failsafe.mode|below]].+      <img src="/_media/meta/icons/tango/48px-emblem-question.svg.png" alt="" style="float:left; margin-right:0.5em" /> 
 +     <strong>Unverified Information!</strong><br /> 
 +     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. 
 +    </td> 
 +  </tr> 
 +</table> 
 +</html> 
 + 
 +=== Under Windows === 
 +  
 +You can employ the  
 +[[http://downloads.openwrt.org/people/florian/recvudp/recvudp-win32.zip|recvudp.exe]] utility software - Launch it. You may also need to temporarily disable firewall. 
 + 
 +==== Stage 3 ==== 
 + 
 +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)=== 
 + 
 +{{:doc:howto:linux-failsafe.png|}} \\  
 + 
 +=== Message under Windows (only the first line)=== 
 + 
 +{{:media:failsafe2.png|}} 
 +==== Stage 4 ==== 
 +Click the 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 5 ==== 
 +Once in failsafe mode, a confirmation message appears (not always, for the TL-WR1043ND no message comes).Sometimes the sys led blinks very quickly.   
 +Leave the listen command and try to  telnet at 192.168.1.1  \\ 
 + 
 + 
 +Now go to section [[#In failsafe mode]] 
 + 
 +==== Remarks ==== 
 +  * If you do not receive this message, immediately after turning the router on, rapidly click and keep clicking the button on the router for about 60 seconds. 
 + 
 +   * 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. 
 + 
 +<html> 
 +<table class="inline" style="width:70%; margin-left:15%"> 
 +  <tr> 
 +    <td style="border-left:6px solid #f57900; vertical-align:middle"> 
 +      <img src="/_media/meta/icons/tango/48px-emblem-question.svg.png" alt="" style="float:left; margin-right:0.5em" /> 
 +     <strong>Unverified Information!</strong><br /> 
 +      In the previous remarks, we cannot know whether click refers to a brief push (one should repeat) or to a long push. <a href="?do=edit">Remove ou adapt </a> these note if you can. 
 +    </td> 
 +  </tr> 
 +</table> 
 +</html> 
 + 
 + 
===== Triggering via keyboard key combination in a serial console ===== ===== Triggering via keyboard key combination in a serial console =====
Line 86: Line 150:
  * 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> (this will reboot the device as part of the process) 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.

Back to top

doc/howto/generic.failsafe.1357503287.txt.bz2 · Last modified: 2013/01/06 21:14 by eugenius