The Netgear DGN2200v3 is a nice low cost Wireless (802.11b/g/n) ADSL2+ router that can be quite easily found. It is a nice piece of hardware and features some interesting features, such an USB host port to connect and share a USB storage device, and expecially is easily customizable for users interested in having a powerfull generic device running a Linux embedded operating system.
Note: this is a heavily “Work in Progress” page so please check it out here and there if you are interested in the topic! (last update 10th March 2013)
First of all you can find the source tree for the router at Netgear site starting from their GPL Open Source Code for Programmers page. The package also contains a suitable toolchain uclibc-crosstools-gcc-4.4.2-1. Everything described in this page refeers to the “official” firmware V1.1.00.10_1.00.10 . It may also apply to future updates and to the beta version that Netgear started to distribute but it may require slight modifications.
The next step to access to your router internals is to enable the telnet shell using the debug backdoor present in the firmware. It is easily done by accessing (we suppose 10.0.1.69 is your router IP address) the URL: http://10.0.1.69/setup.cgi?todo=debug This will enable telnet connections from your local network. Just login with your administrator credentials.
Once you entered you can analyze the running system, briefly:
# cat /proc/version Linux version 2.6.30 (root@BuildServer) (gcc version 4.4.2 (Buildroot 2010.02-git) ) #1 Fri Nov 4 13:30:23 CST 2011 # cat /proc/cpuinfo system type : 963281TAN processor : 0 cpu model : Broadcom4350 V7.5 BogoMIPS : 319.48 wait instruction : yes microsecond timers : yes tlb_entries : 32 extra interrupt vector : no hardware watchpoint : no ASEs implemented : shadow register sets : 1 core : 0 VCED exceptions : not available VCEI exceptions : not available unaligned exceptions : 10 # free total used free shared buffers Mem: 60004 49576 10428 0 3856 Swap: 0 0 0 Total: 60004 49576 10428 # df Filesystem 1024-blocks Used Available Use% Mounted on mtd:rootfs 27648 17096 10552 62% / mtd:factory 256 52 204 20% /config/factory mtd:scnvram 1024 80 944 8% /config/nvram mtd:language 1024 468 556 46% /config/language mtd:xxx 768 68 700 9% /config/xxx
There are especially a few tools that you may find useful for tweaking the router.
- One is wl and permits you to tweak wireless card parameters. One purely visual thing, but I found it annoying to be missing, is to make the wireless led blink when there is some wireless activity (by default it’s just always on). This can be achieved by using the command “wl ledbh 3 7“. A command “wl ledbh 3 14” will keep the led always off and blink just when there is traffic. Try to change the second value between 0 and 15 for various effects. Another more interesting usage for this tool is to change the transmission power to achieve slightly better coverage results. To see the current settings you can use “wl -a wl0 txpwr“. To set a value you can use the “wl -a wl0 txpwr 80” for example to set it to 80mW which is practically the maximum value (by specs at least). Use the –help for a (huge) detailed list of options!
- Another very interesting tool is adslctl. This tool can be used to tweak all the ADSL parameters such as the SNR limits (start –snr) and get additional informations from your link (info –show). Use the –help for a detailed list of options!
Once you are happy with some modifications of course it would be nice to make them stable. If you noticed the mount output the root device is in read-only mode but no fear, just remount it to read-write: mount -n -o remount,rw /
Another important thing to notice is that the /etc/ is not really on flash but it is just a link to a directory that is in /tmp temporary filesystem and that gets re-populated at every boot from the template in /usr/etc. Therefore if you want to make your modifications permanent to the startup scripts you have to work on /usr/etc. For example, considering also that there is no default editor on the system, if you would like to make the led blinking permanent you could execute something like this:
mount -n -o remount,rw / cd /usr/etc echo "/etc/rc.makkapakka &" >> rcS echo "#!/bin/sh" >> /usr/etc/rc.makkapakka echo "/bin/sleep 20" >> /usr/etc/rc.makkapakka echo "/usr/bin/wl ledbh 3 7" >> /usr/etc/rc.makkapakka chmod a+x /usr/etc/rc.makkapakka
This will append a line to the standard rcS file to execute another custom script (rc.makkapakka) which contains the three lines written with the echo redirected to rc.makkapakka. The last line will make sure the script is executable. You’ll notice that there is a sleep of 20 seconds in the script: this is done since during startup also other processes are running and the wireless module gets reinitialized elsewhere. Of course it’s not the most elegant solution since it’s a hard-coded timing, but it works in practice and should be enough for the example (if you want ADSL parameters to be kept you better make the sleep slightly longer since that part takes more time to be initialized at first).
Of course editing files with just the shell tools (such as echo but also cat,head,tail and grep) is not the most confortable thing in the world. Of course you can pre-edit the files on your PC and then upload them either via FTP or put them via the USB storage available. Otherwise check at the bottom of this page for some pre-crosscompiled packages, there is also the GNU nano editor.
About the firewalling rules:
The DGN2200 has a pretty elaborated firewalling rule set. It is quite elaborate also to permit quite “easy” tear down and reload of rules when they are changed by the user on the web interface. There are some nonstandard modules/rulesets used that make the investigation even furtherly complicated. You can have a look for yourself and work out a bit the logic behind the networking system by using:
iptables -L iptables -L -t nat
Something that most probably any of you playing with the DGN2200v3 firmware would want to do is to open a port locally so you can install some service running on the device (for example dropbear or OpenVPN listed below with their binary packages). This sadly cannot be performed via the web interface. The interface will actually permit you to set a “port forwarding” to the IP of the router itself but that will not work for how the rules are then expanded to iptables.
If you would like to open a local port to a running service nevertheless the best, and less invasive, way to do it in my opinion is using the following two rules (that are supposing you’d like to open TCP port 3636):
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 3636 -j ACCEPT iptables -t nat -I PRE_CNAPT 1 -p tcp -s 0/0 -d 0/0 --dport 3636 -j ACCEPT
The first line is quite obvious and will actually permit the input packets to be accepted. The second one is inserted to prevent the CNAP prerouting rule to drop the packets for that specific port.
Now you can put your favorite TCP service on the 3636 port and have it rechable from the WAN side.
Precompiled packages:
Here are some pre-crosscompiled packages for those that don’t want to mess with the crosscompilation process. I tried to make them as easy to use as possible (so you’ll usually find statically linked versions for example if they depend on other libraries) and install:
- GNU tar and GNU gzip for decompressing the other archives offered later in this page. This two tools are offered uncompressed so you can just download them from your router using the build in busybox based wget tool and then proceed to further installation of other packages without needing a decompressor on your PC or so. (thanks to Stuart for this deployment idea!). The tar will search for gzip in the path so make sure you first add the directory where you downloaded gzip to the path (ie. something like export PATH=$PATH:/path/to/gzip/directory). For some packages a warning that the UID/GID of the original package files cannot be restored will appear: don’t worry too much it’s normal since my UID/GID of my developement system are not present on the router. To unpack the packages listed below just use “tar xfz packagename.tar.gz” (again put also tar into the path or use ./ to execute it from the current working directory). Make sure you set both files as executable (chmod a+x tar gzip) aswell. Download tar and gzip here!
- GNU nano text editor version 2.2.6. This version is statically linked (since it uses the the ncurses 5.9 library). It is important to know that the ncurses library needs the terminal information (terminfo) to start. So in the package you will find also a “vt102” file (the default terminal defined on the DGN2200 at login) that has to be placed in the /opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/share/terminfo/v/ directory. If you need other terminal definitions for some reason you can find them in the ncurses package (or on mostly any Linux desktop installation). The nano executable can be placed where you wish. Download nano-dgn2200-bin.tar.gz here!
- Strace system trace analyzer version 4.7. What else do you need when something doesn’t work and you have to understand what? Here it is, download strace-dgn2200-bin.tar.gz
- Dropbear embedded ssh package version 2012.55. The package should include all you potentially need, so client, server and key management tool. Remember eventually to pass using the “-d” and “-r” options the path to the keys where you generated them (the defaults are in /etc/dropbear and are therefore quite volatile). Download dropbear-dgn2200-bin.tar.gz.
Make sure you first generate the keys and then specify the path to the keys to the executable, otherwise the defaults are in /etc and they are missing there.
To create the keys do for example both:
./dropbearkey -t rsa -f /tmp/dropbear_rsa_host_key
and
./dropbearkey -t dss -f /tmp/dropbear_dss_host_key
this will generate the two keys in /tmp (eventually of course you can put them in /opt or other fixed storage).
Then start dropbear pointing to the keys with:
./dropbear -d /tmp/dropbear_dss_host_key -r /tmp/dropbear_rsa_host_key
Be also aware that by default dropbear accepts only users with a shell listed in the /etc/shells file so if you have troubles connecting with a specific user make sure that the used shell is listed in this file.
Another warning: by default the admin user doesn’t have a home directory assigned and therefore the dropbear connection may just hang after autentication. Change it’s home directory in the /etc/passwd file (in /usr to make it non-volatile) to / as root (insert a “/” before the last colon of the line) - OpenVPN 2.2.2 package for creating VPN. To be able to use VPN in some configurations the kernel needs the TUN device support. In the download package you will find the precompiled module tun.ko that you have to load before using the openvpn package (insmod tun.ko). Also remember that you have to create the appropriate /dev/net/tun (char dev, major 10, minopr 200) device. The openvpn has been compiled with the following defines:
ENABLE_CLIENT_SERVER ENABLE_DEBUG ENABLE_EUREPHIA ENABLE_FRAGMENT ENABLE_HTTP_PROXY ENABLE_MANAGEMENT ENABLE_MULTIHOME ENABLE_PORT_SHARE ENABLE_SOCKS USE_CRYPTO USE_LIBDL USE_LZO USE_SSL. Please be aware that apart from configuring properly the openvpn configuration files you need to tweak the iptables (system firewall) settings on the router to achieve some useful/interesting results. More about iptables chains on the DGN2200 for OpenVPN later on since it’s not a short story. For now as a hint: make sure you permit the traffic (LOCAL/INBOUND_FILTER_1) for the tap0 device that OpenVPN uses first of all and then forward the private networks behind the tunnel. Download openvpn-dgn2200-bin.tar.gz. - curl 7.28.1package for advanced file transfers, query generation, various protocols operation and much much more. The default filesystem contains the busybox version of wget which is quite limited (as it should be given it’s a very compact version!). With this package you can manage much much more. The package is compiled with these features:
# ./curl -V curl 7.28.1 (mips-unknown-linux-gnu) libcurl/7.28.1 OpenSSL/1.0.1c Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp Features: Largefile NTLM NTLM_WB SSL TLS-SRP
Download curl-dgn2200-bin.tar.gz.
- netcat version 1.10 the TCP/IP Swiss army knife. Very useful tool to debug networking troubles and services. Download netcat-dgn2200-bin.tar.gz
- coreutils version 8.19. This package contains most of the coreutils that are not present as busybox applets in the router and can be very often of use. Some examples are stty for terminal settings management, seq to create sequences at command line, nohup to start processes without a terminal (for nightly uploads and downloads). Here is a list:
base64 comm factor mkfifo paste sort tac uniq basename csplit fmt mktemp pr split tee uptime chgrp dirname fold nice printenv stat timeout whoami chown du getlimits nl seq stdbuf truncate chroot env id nohup shred stty tsort cksum expand join od shuf sum unexpand
And here is the download coreutils-dgn2200-bin.tar.gz.
- p910nd version 0.93 printer daemon to transform your DGN2200N also in a printer server for your network using an USB printer. I just modified the lockfile to be created at /var/lock instead of /var/lock/subsys to be more compatible with the default router filesystem tree. Download p910nd-dgn2200-bin.tar.gz
- tcpdump version 4.2.1 based on libpcap 1.2.1, the very powerful packet inspector for all your network debugging (and sniffing
) needs. Download tcpdump-dgn2200-bin.tar.gz. - rtorrent version 0.9.3 text-based torrent client. Compiled with libtorrent 0.13.3, libsigc++-2.3.1 and curl-7.29.0. Tried and tested to work well, be aware that you may need to play first a bit with iptables for incoming connections (see above in the iptables section how to open a port for local use) to achieve full speed transfers. Be also aware that when you use it over telnet some character sequences may be “eaten up” by the terminal emulator and telnet itself. Check the notes in the Rtorrent User Guide where it explains how to skip the mappings with stty (you can find stty tool crosscompiled for the DGN2200v3 in the coreutils package above). Download rtorrent-0.9.3–dgn2200-bin.tar.gz.
- GNU screen version 4.0.3. Screen/terminal window manager to give you the possibility to use multiple shells/applications at the same time on a single telnet login and especially leave them working unattended after a logout (useful for example for rtorrent posted above or your favourite IRC session!) and resume them later on when you reconnect. The package contains also two termcap definitions (vt100 and vt102) to make the default terminals work (put them into /opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/share/terminfo/v/ since ncurses was compiled to watch for them there). Download screen-4.0.3-dgn2200-bin.tar.gz.
- CIFS filesystem kernel module, so you can mount CIFS/Samba network filesystems on your DGN2200v3. First insert the module (insmod cifs.ko) and then mount the share with something like:
mount -t cifs //10.36.36.42/test /mnt/shares/U/cifstest/ -o username=guest
or
mount -t cifs //10.36.36.42/test /mnt/shares/U/cifstest/ -o username=user,password=secret
Download cifs-kernel-module-dgn2200-bin.tar.gz.
- rsync 3.0.9 for incremental file/repository transfers. Download it here: rsync-dgn2200-bin.tar.gz
USB Serial package and connecting Arduino boards
One of the interesting things I wanted to do with my router was also to have the possibility to pilot and monitor some external hardware (using digital I/O and high power relays), do some identification using I-Button devices and in another case be able to do some simple room monitoring (temperatures and so on). Being this things done with some easy to find low cost Arduino based prototype boards a very interesting step for my DGN2200v3 modding was to include the support for the USB serial converter used by this boards to be able to have an easy and cheap way of interaction (of course I could also use a ethernet/wireless shield for the Arduino board, but that would make the board prototypes more expensive and complicated).
So here it comes the precompiled package with all the serial drivers needed: download usbserialftdio-dgn2200-bin.tar.gz. The package includes the generic usbserial module, the specific ftdio_sio module and I also included the stty terminal management tool (from the GNU coreutils 8.19 package) to make it easy to work with the serial port even from the command prompt or using shell scripts.
Once the modules are loaded:
insmod usbserial.ko insmod ftdi_sio.ko
When the device is attached you should see it detected by looking at the kernel messages, something like:
ftdi_sio 2-1:1.0: FTDI USB Serial Device converter detected usb 2-1: Detected FT232RL usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0 usbcore: registered new interface driver ftdi_sio ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
Now the device can be used via the device ttyUSB0 (the device may diffeer depending on what else you have attached to the USB hub). Make sure you create a device to be able to access it since by default is not present:
mknod /dev/ttyUSB0 c 188 0
And then you can access it through /dev/ttyUSB0 device. You can use the stty tool in the package to configure the serial communication parameters, for example to set the baudrate to 9600 which is quite classic in Arudino IDE example files you may play with:
stty -F/dev/ttyUSB0 9600
And then you can even use command line tools such as cat to read or echo to write to the serial from a shell script or command prompt. And now you can expand your DGN2200v3 router to make the connected Arduino board interact with additional electronics and so on with a cheap but very reailable setup .
Of course: needless to say that you can use this usbserial+ftdi_sio package also to connect just a standard USB-232 converter to your router if that is usefull to you!
Well done!
I’d like to add the p910nd daemon on the router, can you cross-compile it to make some test please?
And another question: is this sw compatible with dgn2200v1 router (and reverse, too)?
Thanks a lot
D.
Hello there!
I prepared the p910nd as requested, I just tested that it starts and is alive, didn’t have the possibility to have a printer attached at the moment, but I may try later on
Please let me know if the package seems to work to you eventuall so I put it in the official list of the post. Here is the link to download.
The binary is derived from version 0.93 available at p910nd project page. I just modified the lockfile to be created at /var/lock instead of /var/lock/subsys to be more compatible with the default firmware.
As for the binary compatibility of the dgn2200v1 router: I don’t have one to check sadly but the CPU is the same MIPS family so if the filesystem has simillar library versions they could be “binary compatible”.
Ciao!
Ok! Now I have all binaries in my router, but can’t use them.. :/
I’m quite new on embedded systems so don’t exactly know to do how can I use the binaries.
First of all, I put all binaries in /opt directory, and vt102 in /opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/share/terminfo/v/ directory, but running ./nano I got the message “Error opening terminal: vt102.”
No luck even with p910nd and dropbear daemons, running them I can’t find them alives on running processes list generated by ps command.
Can you explain how do you get them up?
Thanks a lot!!
Hello!
For nano please double check the path to the “vt102″ file. That error is specific from the ncurses library that can’t find that file to get the terminal definition, so it would all point to the fact that somehow you didn’t copy correctly the file from the message.
For dropbear: make sure you first generate the keys and then specify the path to the keys to the executable, otherwise the defaults are in /etc and they are missing there.
So for the keys do for example both:
./dropbearkey -t rsa -f /tmp/dropbear_rsa_host_key
and
./dropbearkey -t dss -f /tmp/dropbear_dss_host_key
this will generate the two keys in /tmp (eventually of course you can put them in /opt or other fixed storage).
Then start dropbear pointing to the keys with:
./dropbear -d /tmp/dropbear_dss_host_key -r /tmp/dropbear_rsa_host_key
Now you should see it running and accepting connections!
For p910nd if you start it with –help do you see it working? But if you just start “./p910nd” you should see a process p9100d running indeed. Check that you have the /var/lock and /var/run directories in case where it creates some runtime files.
Are you using the v1 or v3 hardware at the end? Which firmware also do you have?
Ciao!
Thanks for help! So..
Router: dgn2200v3
Firmware: V1.1.00.10_1.00.10
As you said, a third check was needed for the path, the final “s” of toolchains was missing.. eh ehm.. sorry.. at the end.. nano is correctly working
dropbear is also working, but at the beginning I couldn’t login with admin or root user, so checking /etc/passwd I discovered that root is the only user. So I simply solve the problem giving a “passwd” command from telnet debug console, choosing a new root password. After I copy the /etc/passwd to /usr/etc/passwd to make it permanent.
As now I can’t print with p910nd daemon :/
It seems the daemon is correctly running as it creates the pid file in /var/run and of course the port 9100 is discoverable from a client host with nmap.
I tried lounching it with a “#p910nd -f /dev/printer0″ but I think that I have to tell to the router that he has a printer attached to his USB Host port.. but how should I do it?
See ya! Ciao
Hello!
For dropbear maybe the login problem was also depending on the shell. Dropbear permits a login just from the shells listed in /etc/shells and admin user usually has a shell (/sbin/sh) that is not listed there. So another solution may have been just to add /sbin/sh in the /etc/shells file. I noticed I changed this on my device but forgot to write on the article.
Great now nano and dropbear are working
As for the printer you should attach the printer to the USB and check what the kernel is seeing with “dmesg”.
I checked and the USB-Printer driver is compiled in (not as a module but integrated in the kernel). I tried to attach a printer and after some time indeed with “dmesg” command I saw:
usblp0: USB Bidirectional printer dev 2 if 1 alt 0 proto 2 vid 0x04B8 pid 0×080
meaning the printer was seen and recognized as a printer. Try to see if you see something like this. Actually it really depends a lot on the printer model now and how it gets detected. So plug it and check (after some time) with dmesg.
Then as you correctly did you should use /dev/printer0 since that is a device with major/minor 180/0 which is what /dev/usblp0 is usually. You can get this info, if the printer is recognized, also in /sys/class/usb/lp0/dev file. But of course the first step is to see if and how your printer is recognized by the kernel.
Hope it helps!
Ciao,
Pingback: How to cross-compile under Linux | EVOL S.R.L.
Hello! Would you mind if I share your blog with my facebook group?
There’s a lot of people that I think would really enjoy your content. Please let me know. Cheers
hi. if i make changes like the transmission power of the router to 80 is it going to be save until the next reboot or it will be saved until i flash another firmware? tnx
Hello!
If you followed the article guide after “The modifications will be in place till next reboot of your router. If you want to save them permanently you have to ….” then they will be permanent until you change your firmware.
While if you just typed over telnet the “wl” command then they will get lost at next reboot.
Hope it clears out things
Eventually let me know,
Ciao,
F.
First off all many thanks for this awesome guide and software included…
I managed to setup the p910nd daemon and now my DGN2200v3 works as a print server!
All I had to do was to start the daemon with the following:
./p910nd -f /dev/printer0 -i 192.168.1.1
where 192.168.1.1 is the IP of my router on the internal network.
Now to my question…
Is there any way to have the p910nd daemon start automatically when I reboot my router?
Thanks!
Hello Thomas!
Thanks for the kind words!
To make it start automatically you have to add it to the end of the rcS script (in /usr/etc). Please check better the article above, after the part “Therefore if you want to make your modifications permanent to the startup scripts you have to work on /usr/etc. For example, considering also that there is no default editor on the system, if you would like to make the led blinking permanent you could execute something like this:”
Of course if you first upload the nano editor supplied you can make it better
So:
1) Mount the filesystem in rw (mount -n -o remount,rw /)
2) Create the shell script for example /usr/etc/rc.thomas and inside put the commands you would like to execute at boot, so for example (notice that you have to put the entire path to the p910nd executable):
#!/bin/sh
/mnt/shares/U/p910nd -f /dev/printer0 -i 192.168.1.1
3) Make che script executable (chmod a+x /usr/etc/rc.thomas)
4) At the end of the /usr/etc/rcS script call your script, so at the very bottom just add
/etc/rc.thomas &
Hope it helps,
Ciao,
F.
Splendid!
I now have my DGN2200v3 as a fully functional print server, without worrying about having to telnet and restart p910nd if I have to reboot
!
Many thanks once more…
Great Thomas!
Thank to you for your positive feedback!
Have fun modifying the router
F.
Is there a way to create a second PPPOE DSL connection on the 2200v3? We have a VPN service here that works on these exact routers as long as they have the custom firmware from the VPN provider, unfortunately I made a mistake and bought a stock replacement one and now I cannot create a second PPPOE connection that is required for the setup of the VPN.
If you can assist me with this I will be eternally grateful.
Hello,
From the telnet command line you should have everything on the router, as there is pppoe command:
# pppoe -V
Roaring Penguin PPPoE Version 3.5
And there is kernel support for it. Try to check the usage page on a normal Linux box or on a search engine.
Be aware eventually of filters on iptables in case.
Do you eventually have access to the shell of the VPN provider router? In that case you may try to check over there what is running specifically!
Ciao,
F.
Hello again Federico…
Today I have another challenge for your skills
.
.
On my home network I have an IcyBOX NAS that has some SAMBA shares defined.
I’m trying to mount a share on the DGN2200v3 but I get an error that smbfs is not supported by the kernel
Is there any chance for a .ko module that we could insmod to have such support?
Welcome back Thomas!
Don’t worry, no problem! Actually smbfs is obsolete from some time, cifs is suggested so I prepared that one for you!
Here it comes: cifs-kernel-module-dgn2200-bin.tar.gz
Just load it with insmod (insmod cifs.ko) and then to mount use something like:
mount -t cifs //10.36.36.42/test /mnt/shares/U/cifstest/ -o username=guest
Of course replace the IP (10.36.36.42 in example) and share name (test in example) and the mountpoint (/mnt/shares/U/cifstest) where you want to mount the share.
If you need authentication then you should do something like -o username=user,password=pass
I tested with a local guest access share from my Linux box and should be ok, let me know if it worked
Ciao!
F.
Just 3 letters my friend…
WOW!!!
Works like a charm!
…
I can’t wait to find some time to setup my remote server to backup over SSH directly to my IcyBOX
I honestly can’t thank you enough for your help.
Best regards,
Thomas
Hello again…
I hope you won’t hate me for keep asking you for things
.
Any chance for an rsync binary so that I can sync my remote server with my NAS?
Dropbear doesn’t have SFTP capabilities
…
Thanks in advance!
Ciao Thomas,
Don’t worry, takes little time for simple packages so no problem at all
Try here: rsync-dgn2200-bin.tar.gz.
It’s last 3.0.9 version. I just tested it very very briefly since I’m short on time right now, please let me know if it works well so I put it later in the “official” packages list in the article
Ciao!
F.
rsync is working 100%
My DGN2200v3 now serves as a secured remote backup server (rsync over SSH) attached to my IcyBOX NAS.
Federico rulez!!!
Cheers!
Glad it works fine, thanks for the feedback
I like the helpful info you provide in your articles.
I’ll bookmark your weblog and check again here regularly. I am quite sure I’ll learn plenty of new stuff
right here! Good luck for the next!
Hello again…
I’m trying to find how I can send an email from the router via command line.
Since from the web interface we can schedule email sending of logs, I suppose there is a mail sending command somewhere.
I tried “mail” and “sendmail” but I only get the “command not found”…
Any hits dear DGN2200v3 guru
?
Hey Thomas,
The tool already inside the router is “smtpc”. Try to start it without parameters to get an usage pattern:
# smtpc
==========================================================
Usage: ./smtpc [m:s:f:r:h:p:U:P:cv] < files
-m mime type
-s subject
-f from addr (if NULL use recipient)
-r recipient
-h mail server
-p mail port (default=25)
-U user name (ESMTP)
-P password (ESMTP)
-c Clear syslog
-v verbose (DEBUG)
========================================================
This is the one used for reports configurable from the web interface. It is not too advanced (no SSL etc) but check if it is enough for you.
Later on I was planning to crosscompile msmtp when I have a bit of time
Ciao!
F.
Many many thanks Federico!
Now it’s time for me to share a tip for our DGN2200v3
.
As you may have noticed, from the web GUI we can only use DynDNS service for dynamic DNS. Unfortunately DynDNS is no longer free (without “trying” a Pro subscription that you have to cancel).
In order to have dynamic DNS, you can created an account to DNSDynamic.
Then, via Telnet/SSH and nano (or simply echo) create a file (e.g. /etc/ddns) with the following content:
export IPADDR=`/usr/sbin/ifconfig ppp1 | grep 'inet addr:' | cut -d':' -f2 | cut -d' ' -f1`
curl --interface ppp1 --insecure "https://:@www.dnsdynamic.org/api/?hostname=&myip=$IPADDR"
Replace with your email as DNSDynamic, with your password and with your hostname.
Then, create an entry in /etc/crontab in order to execute the script every let’s say 5 minutes.
/usr/sbin/echo "*/5 * * * * root /bin/sh /etc/ddns" >> /etc/crontab
That’s it!
PS:
.
I still can’t find how to automatically add the cron job upon reboot
Adding it to /etc/usr/crontab didn’t do the trick.
It seems /etc/crontab is overwritten by something else on boot…
Thanks Thomas for the very useful information!
One other way to have a free dynamic DNS option that is 100% compatible with Dyndns (actually it’s Dyndns server itself just “rebranded”) is to use the service at https://www.dlinkddns.com (at least until it lasts
you have to register then it practically creates you one dyndns domain for free… one per account)
I’ll check out the crontab and hopefully let you know something interesting
Ciao!
Hey Thomas,
Did my homework
Well the crontab file looks like it’s overwritten by the “rc_apps” executable which does most of Netgear “closed source” operations. (there is no source of this file) So “use the source, Luke” didn’t apply!
This said I studied a bit that executable (sometimes the dark side calls you in such moments!
) and noticed that one of the things it does is also appending at the end of the operations the file /etc/wifi_crontab, if it exists, to the crontab file.
That wifi_crontab file is created when you do WIFI scheduling from the Web interface.
So actually one solution, if you don’t use (or don’t change often since it’s overwritten every time you reconfigure it) the WIFI scheduling is to put your line for crontab in /usr/etc/wifi_crontab and it will be automatically added at every boot.
Hope that is a working solution for you!
Ciao,
F.
Since I don’t use WiFi scheduling, I’ll go along the wifi_crontab route
.
Thanks for the tip!
Hi can you help me building iptable roules for openvpn
I’ve vpn working VPN and i can access application running on the router but i can’t access local lan.
Thanks
Thanks for the great info. I notice that the router has wget so I can get your packages straight to it. But it does not have tar and zip. Any chance you could make tar and zip binaries and add them to your list (not tared or zipped themselves obviously
Has anyone managed to get ext2/3 usb storage working on the dgn2200v3? The manual says it should work but it just does not show up as a share. I know the kernel has ext support and can mount my drive manually by telneting in. dmesg shows the drive is detected but it does not mount it. dmesg also shows this:
FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!So it looks like it tries to mount as FAT even though it is ext (I have tried ext2 and ext3). FAT would be a pain due to the 4gb file limit. I guess I could try NTFS but that just seems wrong on a linux box.
Many thanks,
Stuart
Hello Stuart!
I like a lot the a “live” tar idea to make the deployment of additional packages even easier even when lacking a PC with a few tools nearby
I added in the article body a copy of tar executable uncompressed (and also gzip nearby to handle the gzipped archives) in the ready software!
Thanks for the idea
As for the mount: you’re correct ext3 is supported in the kernel. The real problem is that the application that manages the mounts (rc_apps, it’s closed source) actually forces NTFS/FAT
See here:
mounting %s -> /mnt/shares/%c
/sbin/mkdir -p /mnt/shares/%c
/bin/ntfsmount -o rw,force /dev/%s /mnt/shares/%c
/bin/mount -t vfat -o rw,uid=0,gid=0,umask=000,iocharset=utf8 /dev/%s /mnt/shares/%c
I didn’t check how carefully then it manages to understand if the mount was succesfully, but it may just check the return code probably.
I guess that eventually putting a custom ntfsmount or mount (a shell script with some logic inside) may be a good and clean trick to do the thing
So for example rename ntfsmount to something else and do a shell script instead of ntfsmount that first tries to mount it as ext3 and if not succesfull calls the old binary… it should work
Hope it was of help,
Ciao!
F.
Thanks for the tar and zip. It worked like a dream with telnet open I could just right click in my browser and copy the link and then paste after a wget in the telnet terminal. Really easy.
I have figured a very cludgy hack to get my ext3 drive shared and survive reboots and hot plugging (not unplugging).
I first append this to /usr/etc/samba.conf/smb.conf:
[shares]
comment = Shares
writeable = yes
path = /mnt/shares/
This means whenever samba starts it will share the /mnt/shares directory and therefore I can get at any sub-directories.
In order to get the drive to automount I have slightly adapted this script /usr/etc/usb/usb_m.sh
....
/bin/sleep 3
#first try to mount ext3
/etc/mountExt.sh $1 $2
if [ $? -eq 0 ]; then
#That script worked so we do not need to continue
exit 0
fi
/usr/sbin/rc usb_service mount $1
....
The new bit should be in bold. If the script succeeds then no need to call the closed source mount so we exit with success.
The script itself /usr/etc/mountExt.sh:
#!/bin/sh
rmDir() {
if [ "$(ls -A $1)" ]; then
echo "Not empty"
else
rm -r $1
fi
}
SHARES=/mnt/shares/
if [ ! -d $SHARES/$2 ]; then
mkdir $SHARES/$2
fi
mount -t ext3 /dev/"$1"1 $SHARES/$2
if [ $? -ne 0 ]; then
echo "mount borked it"
rmDir $SHARES/$2
exit 200
fi
nmbd
smbd
This uses the model name of the drive provided by the mount script. It creates a directory in /mnt/shares. I have no way to check what the file system is so we just try and mount it as ext3. If it succeeds then it was ext3 and we start samba. If it fails then it was not ext3 and we delete the directory (ensuring it is empty). We then return an arbitrary non 0 exit code. The main script will use this to determine whether to continue to try the built in mount script for FAT and NTFS.
It is very hacky but it works for me and survives reboot. Limitations are that it will only try and mount the first partition of a drive. The web GUI also does not know anything about the mounted ext3. It will not show up on the list of shares in the settings and it can not be safely removed from there. The only way to unmount is to telnet in and do it manually.
Hope it is useful for others. It should not interfere with the normal working of the usb sharing but if you have problems you can restore the files from you backups or reflash. I see no reason why it would make the router unbootable but it is your own risk.
I have realised that we can easily add to the web frontend as we can write into /www/
If we remount using
mount -n -o remount,rw /
Then we can make our own cgi using shell scripts. If you have the toolchain then could also do it in C but ash is good for most things. As an example if you make a file called samba.cgi an save it in /www/
#!/bin/sh
startSamba() {
/sbin/smbd -D > /dev/null 2>&1
/sbin/nmbd -D > /dev/null 2>&1
}
stopSamba() {
/sbin/killall smbd
/sbin/killall nmbd
while /sbin/ps aux | /sbin/grep -v grep | /sbin/grep -q 'smbd' ; do
/sbin/sleep 1
done
}
echo "Content-type: text/html"
echo ""
case $QUERY_STRING in
*samba=start*)
startSamba
;;
*samba=stop*)
stopSamba
;;
*samba=restart*)
stopSamba
startSamba
;;
esac
echo "Samba is "
if /sbin/ps aux | /sbin/grep -v grep | /sbin/grep -q 'smbd'
then
echo 'running'
start="disabled"
restart=""
stop=""
else
echo 'not running'
start=""
restart="disabled"
stop="disabled"
fi
echo "
Choose action:
Start
Restart
Stop
"
exit 0
You can then browse to http://IPofYourRouter/samba.cgi
You will get a very simple page that tells you if samba is running and lets you start, stop or restart it.
I intend to make myself a page which lets me start and stop samba but also shows all external drives and partitions and lets me mount/unmount them. This is all possible without other dependencies. The only thing I won’t be able to do is show the filesystem of an unmounted drive. The best way to find this would be the file command but it is not on the router.
Will share when done but maybe others can think of ways to add interesting web based controls.
Stuart
The comments system is eating the HTML code in the script. TTo see the script properly check here:
Hey Stuart,
Thanks for the great feedback!
I’ll see if I can prepare the file or some simillar tool (like blkid or so) for the DGN so you can also give informations about umounted devices as you say!
Ciao.
F.
Pingback: Устранение проблем при работе с NETGEAR N300 DGN2200v3 | asfdfdfd
Excellent work !! I’ve been trying to compile nmap for my WNR3500LV2 but in vain. Did you ever tried to compile nmap as no matter which tutorial I follow, the toolchain cannot be compiled
TY
Hello,
Well nmap is quite a nice beast! With libpcap and expecially liblua as a dependancy is quite problematic with the uClinux based toolchain.
If a version without the lua extension is fine for you then you can find now one working one here: nmap-6.25-nolua-dgn2200-bin.tar.gz.
Decompress it where you like then since it needs also the libpcap library either put it in a library directory or use it with the LD_LIBRARY_PATH variable, ie:
LD_LIBRARY_PATH=. ./nmap -vAlso given the limited uClibc you cannot use the epoll engine so append a
--nsock-engine pollto your classic command line. (or otherwise select)To compile it without LUA there is this bug to be aware eventually.
Hope it helps! For a fully featured lua version some more time and patience would be needed
ciao!
F.
Much appreciated !!!!!
I’ll be using the – nmap-6.25-nolua-dgn2200-bin.tar.gz as advised by you. But to use this do we have to shift from the original netgear firmware to tomato and dd-wrt??
My apologies for being so demanding but your help would be once again highly appreciated
The package is for the standard Netgear firmwares (both beta and not). It should anyway work on other simillar/alternative firmwares if the libraries are roughly simillar (and of course the architecture), give it a try eventually
Ciao!
F.
With your inputs, I was finally able to cross-compile nmap for wnr3500lv2.
For copying the nmap generated information, I cross-compiled WPUT successfully. But the problem is that wput is not able to connect to any ftp server and says permission denied. On the ftp server there is no hit/log.
Is it something with the compilation ??? The same command works from the windows and linux system that are connected to the same router.
TY
Hello,
I checked the code of wput and tried why doesn’t it work. The problem is that some calls return, as it should be being non-blocking, an EINPROGRESS error code but the source is checking for some *hardcoded* values and not for the EINPROGRESS define. This is of course not portable and compiler dependant!
Infact if you check the code in socketlib.c you’ll find:
if(errno > 0 && errno != 115 && errno != 36)That is not very polite to use. You should replace it with:
if(errno > 0 && errno != EINPROGRESS)And then it should work!
Ciao!
f.
After recompiling WPUT with – if(errno > 0 && errno != EINPROGRESS), now Im stuck at error – connecting to xxx.xxx.xxx.xxx………. failed. No matter which FTP I specify, the error in displayed instantenously.
Hello!
That is strange mmm… Are you sure there aren’t on that router some limitations to outgoing connection from the router itself?
You could try for example with another client (for example curl that is on the article to download) to see if that works. Or eventually, more technical solution, try to run WPUT with strace (also on the page above) so you see what call fails (I debugged the EINPROGRESS problem like this indeed). As for DGN2220v3 I tried WPUT on one single FTP upload and it worked. In case here is the dgn2200 version compiled wput-0.6.1-dgn2200-bin.tar.gz.
Ciao
F
Hello,
I did compiled the curl and it works perfectly fine. It seems that the issue is with wput.
Thanks again for your help..
Hi
Yesterday I flashed this router with the new firmware, but now all light are on and recovery mode doesn’t work!
And suggestions about how to recover the router and have it working again?
Perhaps something like JTAG?
Hi,
Switch off the router, then keep the reset button pressed and power on the router. If the leds start blinking (like when you do web upgrade) it may be recoverable since it goes in flashing mode.
Then get this program here for Windows XP (some report troubles with 7 and later) and use this firmware here with the program to flash it (copy dgn2200v3.bin inside the utility directory). The program is originally for the DGN834 but works also with the 2200.
Connect to the ethernet port, when the router is in the blinking state start the program and have a lot of patience for the operation to finish. There is a little guide inside the ZIP file, just be sure you put the right firmware as linked.
Hope it helps!
Otherwise you could get out the serial / JTAG but it’s quite a longer road.
Ciao,
F.
Pingback: TOR+Privoxy minimal setup for DGN2200v3/MIPS architecture | EVOL S.R.L.
Reboot DGN2200 Every day at 5:00
Thanks for all info you provide above:
I used it to set my router to reboot everyday and the steps I used are below in case someone else needs it.
Enable debug mode
URL: http://routerip/setup.cgi?todo=debug
On this router it does let you set 192.168.1.1 to respond to telnet otherwise would need to do it local
So setup firewall rules to enable telnet calls from off site
Mount system file to read and write
mount -n -o remount,rw /
change work directory and install tar, gzip and nano
cd /usr/etc
PATH=$PATH:/usr/etc
Will need to download the files on this zip to the router the router has wget installed already.
Probably upload the files to a ftp server and download from there:
the file tar and gzip need to be change to exectubles
chmod a+x tar gzip
tar xfz nano-dgn2200-bin.tar.gz
Create a folder
mkdir opt
cd opt
mkdir toolchains
cd toolchains
mkdir uclibc-crosstools-gcc-4.4.2-1
cd uclibc-crosstools-gcc-4.4.2-1
mkdir share
cd share
mkdir terminfo
cd terminfo
mkdir v
cd v
cp /usr/etc/vt102 /opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/share/terminfo/v/vt102
cd /usr/etc
nano crontab
add the line
0 5 * * * root /sbin/reboot
My God, you are a saviour !!!!!
Thank you very much for your time and efforts.
Very good article! We are linking to this great post on our
website. Keep up the great writing.