TFTP Server via Netgear DB834GT

I’ve written a short guide on how to configure a Netgear DB834GT (and possibly other variants of the DB834) to forward a device to a TFTP server, via the router’s built-in busybox/linux-based udhcpd server. I’ve recently been setting up a Cisco IP phone at home, and this functionality has proven to be extremely useful.

Disclaimer: I am NOT responsible if you screw up, over-write your config, brick your router, forget your password, kill your dog or set fire to the living room. There’s no reason why you should do any of these things, given the simple commands below, but if you do see fit to go a-wandering through the files stored within your router, then it’s not my fault if you break it!

Anyway, to start, you’ll need to enable the debug mode on your Netgear router. Simply construct a link like the one below, paste it into your web browser and login with your username (most-likely ‘admin’) and the configured password:

http://192.168.0.1/setup.cgi?todo=debug

Of course, you’ll need to replace ’192.168.0.1′ with the LAN IP that you’ve chosen for your router.

Now for the fun part. We need to see what the DHCP server is configured to do at present, so issue the following command:

cat /etc/udhcpd.conf

You should see the contents of the udhcp.conf file printed out. It will look something like this:

server 192.168.0.1
start 192.168.0.20
end 192.168.0.254
interface br0
option subnet 255.255.255.0
option router 192.168.0.1
option dns 208.67.222.222
option dns 208.67.220.220
option lease 259200

To setup the TFTP server re-direction, you first need to add a line to this config file. I had to look up a sample config file for udhcpd, but thankfully it lists a number of DHCP options that can be utilised (but aren’t directly supported by the web interface) to extend its usefulness.

Sadly there’s no text file editor included on the router, but one can achieve the same effect with simple shell operators:

echo "option tftp 192.168.0.20" >> /etc/udhcpd.conf

This simply prints a line and appends it to the file. You can check your addition by using the ‘cat’ command above.

Now you need to stop the DHCP server and restart it. This is so that udhcpd will re-load it’s configuration file and take note of your changes. If you issue the command ‘ps’, you’ll see something like this:

# ps
PID Uid VmSize Stat Command
1 root 252 S init
2 root SWN [ksoftirqd/0]
3 root SW< [events/0]
4 root SW< [khelper]
5 root SW< [kblockd/0]
17 root SW [pdflush]
18 root SW [pdflush]
19 root SW [kswapd0]
20 root SW< [aio/0]
26 root SW [mtdblockd]
104 root 244 S /sbin/klogd
147 root 400 S /usr/sbin/hostapd -B /etc/hostapd.conf
163 root 260 S /usr/sbin/netgear_ntp -z GMT+0 -h 208.69.32.170
165 root 256 S /usr/sbin/mini_httpd -d /www -r NETGEAR DG834GT -c *
172 root 268 S /sbin/syslogd -f /etc/syslog.conf
173 root 244 S /usr/sbin/crond
175 root 168 S /usr/sbin/scfgmgr
179 root 184 S /usr/sbin/cmd_agent_ap
180 root 168 S /usr/sbin/pb_ap
193 root 252 S init
602 root 220 S /usr/sbin/utelnetd -d
1835 root 524 S /usr/sbin/pppd plugin pppoa 0.38 user lol@adsl.net
2056 root 300 S /usr/sbin/reaim
2153 root 244 S /usr/sbin/udhcpd /etc/udhcpd.conf
2155 root 396 S /bin/sh
2157 root 268 R ps

As you can see by this line:

2153 root 244 S /usr/sbin/udhcpd /etc/udhcpd.conf

..the udhcpd server is running with PID 2153. To stop it, just kill it:

kill 2153

Note: Although my example shows udhcpd using PID 2153, yours will most-certainly be different, so remember to substitute the the kill command above with one that uses the correct PID value. Killing the wrong PID could mean that you break something vital, and you’ll need to start over again (ie. restart the router, and go back to the beginning of this guide.)

Issuing ‘ps’ once more should show that the udhcpd server has been sucessfully stopped (it won’t appear in the list of running processes). The router won’t restart udhcpd by itself thankfully. Note that whilst you have the DHCP server disabled, any clients expecting a lease or renew won’t get it. I can only recommend that the machine you do this from is assigned a static IP, to avoid any [possible, however unlikely] hassle.

Since we’ve pre-edited the udhcpd.conf file, all that is left to do is restart udhcpd:

/usr/sbin/udhcpd /etc/udhcpd.conf &

The ampersand at the end is important, don’t forget it!

Finally, issue another ‘ps’ command to check that udhcpd has been restarted successfully, and you’re all done.

Unfortunately these changes will not be permanent. If your router is restarted, or power cycled, you will lose these settings. At present, I do not know of a way to successfully add the TFTP option to the configuration saved within the router’s non-volatile memory. It would be nice if Netgear could build some of this functionality into their firmwares (and thus the web interface), and whilst third-party firmwares do exist, I’ve not had the beef to test one out as of yet.

Still, this helped me configure my SIP phone, so hopefully it’ll help someone else. :)

One Comment

  1. peter says:

    busybox does allow you to compile and install the ‘bin/busybox’ binary in a target directory, this would make the changes permanent for udhcpd on the Netgear

    http://linux.die.net/man/1/busybox

Leave a Reply

You must be logged in to post a comment.