Setting Up TFTP Server in Linux Mint 12

I am in the process (and actually have been for the past 5 years) of studying for my Cisco certification, specifically now, the CCENT. One of the labs I wanted to familiarize myself with was copying a config from a switch or router to a TFTP server. Eventually, I want to test the boot of an IOS on that TFTP server too. I had purchased an old Catalyst 2950 on Amazon a little over a year ago and recently had to start using it full time as one of my switches in my LAN because my DLink died a little over a week ago. No problem there except for the noise and heat that the 2950 puts out. But the advantage of it is that I can use it as a live lab. No worries there also since it doesn’t really have high traffic devices connected to it, just my Xbox 360, Media PC, and NAS; those are devices I don’t use all the time.

Well, since I use Linux Mint 12 on my desktop I needed to setup TFTP server on it so that I could backup my switch config to it for practice. Trying to find the best setup of TFTP server in Linux Mint wasn’t the easiest find. After numerous searches and a couple of failed How-To’s I finally came across this blog post for Ubuntu.

How to Setup TFTP on Ubuntu 11.10

There was a couple of changes in my configuration though that I had to make for my personal preference, nothing big, and I found that I didn’t need the following:

sudo chown -R nobody:nobody /var/lib/tftpboot

However, if you are using Ubuntu, or other like distribution, you still may need it so I would not skip it if I were you.

Here is the entire post just in case at the time of reading my post the external link no longer exist.

———————————————————————————————————-

First, let’s install all the necessary packages:

sudo apt-get install xinetd tftpd tftp -y

Next, we need to create a configuration file:

sudo nano /etc/xinetd.d/tftp

Put the following content into the file.

service tftp
{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = var/lib/tftpboot -s
   disable = no
}

In the server_args, I have var/lib/tftpboot, which represents the location of the tftp root, i.e., /var/lib/tftpboot. Notice that I skip the root /.

Now let’s change the ownership of the directory:

sudo mkdir /var/lib/tftpboot
sudo chown -R nobody:nobody /var/lib/tftpboot
sudo chmod -R 777 /var/lib/tftpboot

and start the TFTP service:

sudo service xinetd stop
sudo service xinetd start

Verify the TFTP is running correctly or not:

netstat -na | grep LIST | grep 22

You should see something like this:

tcp        0      0 0.0.0.0:22              0.0.0.0:*     LISTEN

 

 

Test: Upload a file to TFTP Server

Now let’s test the TFTP server by logging into the server first:

tftp localhost

and upload a file:

tftp> put myfile.jpg
Sent 56733279 bytes in 5.7 seconds

Quit:

q

Make sure that file has been uploaded:

ls -l /var/lib/tftpboot

Test: Download a file from TFTP Server

Now, let’s go to a different directory and download the file we just upload.

cd some_other_directory

and log in to the tftp server again:

tftp localhost

and get the file:

tftp> get myfile.jpg
Received 56733279 bytes in 5.7 seconds

You are done.

Troubleshooting (e.g., Error code 2: Access violation)

If you see a message like: Error code 2: Access violation

Make sure that you:
– Follow the exact procedure in this tutorial
– Make sure that the tftp is started with -s flag.
– Check the permission of the directory, i.e., 777
– After you’ve made any changes to the TFTP configuration, make sure that you stop and start the inet service again.
– Don’t forget to quit tftp before retrying the command.

————————————————————————————————-

Thanks to Derrick over at Icesquare for the very informative post.

Advertisements

2 thoughts on “Setting Up TFTP Server in Linux Mint 12”

  1. “Dear” author 😀 ….. FTP services run on port 21 😉

    Verify the TFTP is running correctly or not:

    netstat -na | grep LIST | grep 22

  2. Well… the comment above is right: there is an error in verification, but the given solution is also WRONG.

    TFTP is *not* FTP. (isn’t it obvious?)

    And it uses UDP not TCP, listening on port 69 (grep tftp /etc/services).

    shell$ netstat -na | grep “:69\s”
    udp 0 0 0.0.0.0:69 0.0.0.0:*

    or

    shell$ netstat -lu | grep “:tftp\s”
    udp 0 0 *:tftp *:*

    Cheers,
    S.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s