![]() |
Set up NSLU2 as tftp server using Unslung firmware Charlie Dionne (charles.dionne_at_hstx.com) Harris Stratex Networks 9/22/2007 Acknowledgement: This document owes some of it's content to Alastair Bor's web page: "Find out about building a compact home PABX" (www.ambor.com/public/home_pabx/home_pabx.html) as well as to the NSLU2 Linux web site (www.nslu2-linux.org). Why This Document: There are lots of "how-to's" about setting up a tftp server on the NSLU2. However, the typical application seems to be for VoIP phones, diskless workstations, and other devices that need to download their firmware and configs at bootup. This only requires files to be copied from the NSLU2 which is exactly what the tftpd-hpa software does out of the box. However, the application I had in mind was to copy config files and IOS images from a switch or router both to and from a tftp server and that requires extra steps. These extra steps didn't seem to be in any one place, so I wrote this document. Introduction: The Linksys NSLU2 was designed to share a USB drive over a home network. It does this by running SAMBA, a Linux program that emulates a Windows file server. The Unslung firmware is an enhancement of the standard NSLU2 firmware that lets programs run from the external USB drive and so frees the NSLU2 to be used for other things besides a Windows file server. In this case, it will be a tftp server used to store config files and IOS images. Note: When installation is done, the USB flash drive is formatted with a Linux file system that can't be read from a Windows box. Removing the flash drive from the NSLU2 would also disable the tftp server. The procedure: 1. Download the Unslung firmware from www.nslu2-linux.org (there are several other firmwares available - this procedure refers specifically to Unslung rather than SlugOS, OpenWRT?, etc.). Follow the instructions in the readme file included with the firmware. Use either the upslug utility on a Linux box or the Sercomm Upgrade Utility on a Windows box to flash the new firmware to the NSLU2. The Sercomm utility is a little rough around the edges. If it doesn't work the first time, try selecting different interfaces from the dropdown list. Once the firmware and USB drive are installed, go to the Web GUI (192.168.1.77 is the default IP address) and login as: User: admin Password: admin Enable telnet from the Web GUI. Later, we'll configure telnet to be enabled on startup so we won't have to do it manually. The Web GUI is also an easy way to change IP addresses, etc. Another useful thing we can do while in the Web GUI is to disable UPNP which will free up a little more RAM. 2. Now telnet into the NSLU2 as root: C:\>telnet 192.168.1.77 Trying 192.168.1.77 ... Open LKGA22641 login: root Password:uNSLUng (uNSLUng is the default password) No directory, logging in with HOME=/ Welcome to Unslung V2.3R63-uNSLUng-6.8-beta ---------- NOTE: THIS SYSTEM IS CURRENTLY UNSLUNG ---------- BusyBox v0.60.4 (2005.03.22-06:52+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. # The first thing we'll do is extend the life of the USB flash drive by disabling file swapping and time stamping by typing the following from the command line: # touch /.ext3flash This won't take effect until the next reboot. Next, update the list of available software packages (this won't work unless there's an internet connection): # ipkg update 3. Install the following software (once again, an internet connection is required): # ipkg install tftp-hpa (a tfpt server) # ipkg install nano (a text editor) # ipkg install xinetd (the Linux "super server") 4. Nano is a small text editor that will be useful because several of the following tasks require us to work with text files. It's located in the /opt/bin directory once installed. For example: # /opt/bin/nano /opt/etc/xinetd.conf (opens xinetd.conf file) 5. Check that /opt/etc/xinetd.conf has the following:
defaults
{
only_from = 0.0.0.0/0
instances = 60
log_type = SYSLOG authpriv info
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /opt/etc/xinetd.d
Changing the only_from argument removes the subnet restriction so you won't have to modify the .conf file if you choose later to change IP address and subnet. 6. Also check that /opt/etc/xinetd.d/tftp looks like this:
service tftp
{
flags = REUSE
socket_type = dgram
protocol = udp
instances = 30
wait = yes
user = root
server = /opt/sbin/in.tftpd
server_args = -vt 30 -c -s /opt/tftpboot
cps = 100 2
log_on_success = HOST PID
log_on_failure = HOST
disable = no
}
At first, the default setup only allows overwriting existing files so the -c option has to be added to server_args as shown above. The last server_args option (-s /opt/tftpboot) in the tftp file insures that all files will be deposited on the /opt/tftpboot directory so you don't have to specify where to put your files or remember which directory you put them in later. Finally, check that /opt/etc/xinetd.d/telnetd looks like this:
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/telnetd
log_on_success = HOST PID
log_on_failure = HOST
disable = no
}
Now go to: # cd /share/flash/data/unslung and using nano create a file called rc.xinetd: # /opt/bin/nano rc.xinetd Paste the following into the file and save it: #! /bin/sh if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then echo "telnet stream tcp nowait root /usr/sbin/telnetd" >> /etc/inetd.conf fi return 1 This will enable telnet on startup so you won't have to go through the Web GUI again. 7. We need to change permissions and ownership for /opt/tftpboot so that files can be written to it. First, copy any file into the /opt/tftpboot directory so we can see the changes work. I chose /opt/etc/xinetd.conf: # cp /opt/etc/xinetd.con /opt/tftpboot Now set permissions: # chmod -R 777 /opt/tftpboot # chown -R nobody.nobody /opt/tftpboot # cd /opt # ls -l drwxr-xr-x 2 root root 4096 Mar 14 14:34 bin drwxrwxr-x 2 root root 4096 Mar 14 14:06 doc drwxr-xr-x 4 root root 4096 Feb 17 2007 etc drwxr-xr-x 2 root root 4096 Mar 14 14:28 lib drwxr-xr-x 5 root root 4096 Mar 14 14:34 man drwxr-xr-x 2 root root 4096 Mar 14 14:34 sbin drwxr-xr-x 7 root root 4096 Mar 14 14:28 share drwxrwxrwx 2 nobody nobody 4096 Mar 14 14:52 tftpboot # cd tftpboot # ls -l -rwxrwxrwx 1 nobody nobody 411 Apr 6 13:07 xinetd.conf You'd probably guess that read/write permission would be adequate (chmod -R 666). Trial and error seems to show that read/write/execute permission is necessary (chmod -R 777). 8. Try to tftp a file to the NSLU2 using the built-in tftp utility on Windows XP and whatever text file happens to be in your current directory: C:\>tftp 192.168.1.77 put Motorola_Driver_Log.txt Whether you use Windows or Linux to do this, make sure your built-in firewall isn't blocking tftp. A network sniffer like Wireshark (formerly Ethereal) may be helpful. Timeouts indicate this sort of problem while error messages like "permission denied" or "file not found" indicate configuration problems. Back on the NSLU2 command line, you should be able to see the file now: # ls Motorola_Driver_Log.txt xinetd.conf # 9. All that's left to do is to connect an actual router and try copying a config file and IOS image to the tftp server. First, physically connect the router to the network, log on, and configure the interface: Router#conf term Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int e0/0 Router(config-if)#ip address 192.168.1.99 255.255.255.0 Router(config-if)#^Z *Mar 1 00:04:11.195: %SYS-5-CONFIG_I: Configured from console by console Router#show interface e0/0 Ethernet0/0 is up, line protocol is up Hardware is AmdP2, address is 0002.b936.d080 (bia 0002.b936.d080) Internet address is 192.168.1.99/24 (etc.) 10. Now check connectivity between the router and NSLU2: Router#ping 192.168.1.77 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.77, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/201/1002 ms 11. Telnet into the NSLU2 and check the contents of /opt/tftpboot: # cd /opt/tftpboot # ls -l -rw-rw-rw- 1 nobody nobody 16635 Apr 10 11:44 Motorola_Driver_Log.txt -rwxrwxrwx 1 nobody nobody 411 Apr 6 13:07 xinetd.conf # exit [Connection to 192.168.1.77 closed by foreign host] 12. Now let's copy some files from the router to the tftp server: Router#copy run tftp Address or name of remote host []? 192.168.1.77 Destination filename [router-confg]? !! 843 bytes copied in 1.943 secs (434 bytes/sec) Router#dir Directory of flash:/ 1 -rw- 15165060 <no date> c2600-j1s3-mz.122-15.T9.bin 16252928 bytes total (1087804 bytes free) Router#copy flash tftp Source filename []? c2600-j1s3-mz.122-15.T9.bin Address or name of remote host []? 192.168.1.77 Destination filename [c2600-j1s3-mz.122-15.T9.bin]? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(etc.) 15165060 bytes copied in 94.407 secs (160635 bytes/sec) 13. Let's see if the files are on the /opt/tftpboot directory: Router#telnet 192.168.1.77 Trying 192.168.1.77 ... Open LKGA22641 login: root Password: No directory, logging in with HOME=/ Welcome to Unslung V2.3R63-uNSLUng-6.8-beta ---------- NOTE: THIS SYSTEM IS CURRENTLY UNSLUNG ---------- BusyBox v0.60.4 (2005.03.22-06:52+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. # cd /opt/tftpboot # ls -l -rw-rw-rw- 1 nobody nobody 16635 Apr 10 11:44 Motorola_Driver_Log.txt -rw-rw-rw- 1 nobody nobody 15165060 Apr 11 03:33 c2600-j1s3-mz.122-15.T9.bin -rw-rw-rw- 1 nobody nobody 843 Apr 11 03:30 router-confg -rwxrwxrwx 1 nobody nobody 411 Apr 6 13:07 xinetd.conf # exit [Connection to 192.168.1.77 closed by foreign host] Router#exit 14. We're done! Other things to try: -copy files from the tftp server to the router -boot the router from the tftp server instead of flash |