Ensure that NMRP packets are at least 64 bytes
[oweals/nmrpflash.git] / README.md
1 nmrpflash - Netgear Unbrick Utility
2 ====================================
3
4 This program uses Netgear's [NMRP protocol]
5 (http://www.chubb.wattle.id.au/PeterChubb/nmrp.html)
6 to flash a new firmware image to a compatible device. This utility has been
7 successfully used on a Netgear EX2700 and DNG3700v2, but is likely to work
8 with many other Netgear routers as well.
9
10 Prebuilt binaries for Linux, OS X and Windows are available
11 [here](https://github.com/jclehner/nmrpflash/releases)
12 ([WinPcap](https://www.winpcap.org/install/default.htm) is required on Windows).
13
14 ```
15 Usage: nmrpflash [OPTIONS...]
16
17 Options (-i and -f and/or -c are mandatory):
18  -a <ipaddr>     IP address to assign to target device
19  -A <ipaddr>     IP address to assign to interface
20  -c <command>    Command to run before (or instead of) TFTP upload
21  -f <firmware>   Firmware file
22  -F <filename>   Remote filename to use during TFTP upload
23  -i <interface>  Network interface directly connected to device
24  -m <mac>        MAC address of target device (xx:xx:xx:xx:xx:xx)
25  -M <netmask>    Subnet mask to assign to target device
26  -t <timeout>    Timeout (in milliseconds) for regular messages
27  -T <timeout>    Time (seconds) to wait after successfull TFTP upload
28  -p <port>       Port to use for TFTP upload
29  -R <region>     Set device region (NA, WW, GR, PR, RU, BZ, IN, KO, JP)
30  -v              Be verbose
31  -V              Print version and exit
32  -L              List network interfaces
33  -h              Show this screen
34 ```
35
36 ### Using nmrpflash
37
38 Your Netgear router must be connected to your network using an
39 Ethernet cable. The device running `nmrpflash` must be connected
40 to the same network, using either Wi-Fi or Ethernet.
41
42 All available network interfaces can be listed using
43
44 ```
45 # nmrpflash -L
46 eth0      192.168.1.2  f2:11:a1:02:03:b1
47 ```
48
49 Once you've determined the interface to use, we can flash the image. Firmware
50 images can usually be downloaded directly from Netgear. For details on how to
51 do this, see [here](#obtaining-firmware-images). Power on your device immediately
52 after starting `nmrpflash`.
53
54 ```
55 # nmrpflash -i eth0 -f EX2700-V1.0.1.8.img
56 Advertising NMRP server on eth0 ... /
57 Received configuration request from a4:2b:8c:00:00:01.
58 Sending configuration: ip 10.164.183.252, mask 255.255.255.0.
59 Received upload request: filename 'firmware'.
60 Uploading EX2700-V1.0.1.8.img ... OK
61 Waiting for remote to respond.
62 Remote finished. Closing connection.
63 Reboot your device now.
64 ```
65
66 ### Common issues
67
68 In any case, run `nmrpflash` with `-vvv` before filing a bug report. Also,
69 try connecting your Netgear router *directly* to the computer running
70 `nmrpflash`.
71
72 ###### "Error while loading shared libraries: libpcap.so.0.8" (Linux)
73
74 You must install your Linux distribution's `libpcap` package. In
75 openSUSE or Ubuntu for example, install `libpcap0.8`. Other distros
76 will have a similarily named package.
77
78 ###### "The program can't start because wpcap.dll is missing" (Windows)
79
80 Install [WinPcap](https://www.winpcap.org/install/default.htm).
81
82 ###### "No suitable network interfaces found."
83
84 Make sure the network interface is up (wireless interfaces are not supported).
85 On Windows, try restarting the WinPcap service (commands must be run as
86 administrator):
87
88 ```
89 C:\> net stop npf
90 C:\> net start npf
91 ```
92
93 ###### "No response after 60 seconds. Bailing out."
94
95 The router did not respond. Try rebooting the device and run `nmrpflash` again.
96 You could also try running `nmrpflash` with `-m` and specify your router's
97 MAC address. It's also possible that your device does not support the NMRP protocol.
98
99 ###### "Timeout while waiting for initial reply."
100
101 The device did not respond to `nmrpflash`'s TFTP upload request. By default,
102 `nmrpflash` will assign `10.164.183.252` to the target device, while adding `10.164.183.253`
103 to the network interface specified by the `-i` flag. You can use `-a` to change the IP
104 address assigned to the target (e.g. if your network is `192.168.1.0/24`, specify a *free*
105 IP address, such as `-a 192.168.1.252`), and `-A` to change the IP address used for the
106 network interface.
107
108 This error message could also indicate a bug in the TFTP code; try using an external tftp
109 client (busybox in this example), by specifying the `-c` flag instead of the `-f` flag:
110
111 `# nmrpflash -i eth0 -c 'busybox tftp -p -l EX2700-V1.0.1.8.img $IP'`
112
113 The environment variable `IP` is set by `nmrpflash` (other environment variables
114 are: `MAC`, `PORT`, `NETMASK`).
115
116 ###### "Timeout while waiting for CLOSE_REQ."
117
118 After a successful file upload, `nmrpflash` waits for up to 5 minutes for an
119 answer from your device. You can increase this by specifying a longer timeout
120 using `-T` switch (argument is in seconds).
121
122 It's entirely possible that the image was flashed successfully, but the
123 operation took longer than 5 minutes.
124
125 ###### "Address X/Y cannot be used on interface Z."
126
127 `nmrpflash` refuses to use an IP address / subnet mask combination that would
128 make the remote device unreachable from the device running `nmrpflash`. For
129 example, if the IP address of your computer is 192.168.0.1/255.255.255.0, assigning
130 192.168.2.1/255.255.255.0 to the router makes no sense, because the TFTP upload will
131 fail.
132
133 ###### "IP address of X has changed. Please assign a static IP to the interface."
134
135 This can happen if the network interface in question automatically detects that
136 the network cable has been connected, and your computer tries to reconfigure that
137 interface (NetworkManager on Linux does this for example) - this can usually be
138 disabled.
139
140 An alternative would be to add `-c 'ifconfig <interface> <ip>'` to the command line,
141 for example:
142
143 `# nmrpflash -i eth0 -a 192.168.1.1 -f firmware.bin -c 'ifconfig eth0 192.168.1.2'`
144
145 This will execute the command specified by `-c` prior to starting the TFTP upload (in
146 this case setting the IP address to 192.168.1.2).
147
148 ### Building and installing
149 ###### Linux, Mac OS X, BSDs
150
151 ```
152 $ make && sudo make install
153 ```
154
155 ###### Windows
156
157 The repository includes a
158 [DevCpp](http://sourceforge.net/projects/orwelldevcpp/)
159 project file (`nmrpflash.dev`). Download the latest
160 [WinPcap Developer Pack](https://www.winpcap.org/devel.htm)
161 and extract it into the root folder of the nmrpflash sources.
162
163 ### Obtaining firmware images
164
165 Firmware images can be downloaded directly from Netgear's FTP servers. 
166 For the Netgear EX2700 for example, download 
167 ftp://updates1.netgear.com/ex2700/ww/fileinfo.txt. At the top there 
168 should be an entry like this:
169
170 ```
171 [Major1]
172 file=EX2700-V1.0.1.8.img
173 ...
174 ```
175
176 The download link for the latest firmware image for this device is thus:
177 ftp://updates1.netgear.com/ex2700/ww/EX2700-V1.0.1.8.img. Substitute 
178 `ex2700` for your device (`wndr4300`, `wndr3700`, `r6100`, etc.). If
179 neccessary, substitute `ww` (world-wide) for a specific region.
180