Community discussions

MikroTik App
 
vddsd
just joined
Topic Author
Posts: 16
Joined: Wed Jul 04, 2012 1:12 am
Location: NB, Canada

TFTP - Set tftp root directory

Tue Aug 14, 2012 3:01 am

Greetings,

I've been trying to figure out the solution to my rather simple problem on and off during the past two days to no avail and I'm hoping someone on here knows the answer to my problem.

Basically I'm trying to setup a TFTP servers on my RB751 routers in order to allow my PXE clients to download their images and boot from them. My issue is that I have no clue how to set the tftp root directory. I figure it has something to do with the "real filename" field, but I'm unable to find the proper combination.

I installed a new USB drive onto the RouterBoard and formatted the drive properly. I then created a directory called tftproot onto drive USB1 and moved my files into that directory. (73 files, scattered in 14 sub-directories. Using a DOS-based tftp client, I'm able to query the TFTP server and download files using their full path (ex: usb1/tftproot/pxelinux.cfg/01-00-08-74-ab-58-0c), it works properly. My issue is that my clients are querying the root directory of the TFTP server, and not the full path... so for example, the file above would be queried as "pxelinux.cfg/01-00-08-74-ab-58-0c".

So basically, to restate my question, is there a way to tell the TFTP server what the root directory is. In this example, the root directory would be "usb1/tftproot/".

Thanks,

Shaun
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TFTP - Set tftp root directory

Tue Aug 14, 2012 1:24 pm

you just add tftp rules and place files where you want to.
 
vddsd
just joined
Topic Author
Posts: 16
Joined: Wed Jul 04, 2012 1:12 am
Location: NB, Canada

Re: TFTP - Set tftp root directory

Tue Aug 14, 2012 4:25 pm

Thanks for the prompt reply to my question. I'm aware of the ability to map a file in a 1:1 fashion... I've tested this and it works quite well. Unfortunately it wouldn't be very efficient for our staff to update our 50+ Mikrotik routers on a daily basis this way.

The issue is the files contained within the "tftproot" directories change on a daily basis from a centraly managed spot, and from there, they have to be pushed to all other routers/TFTP servers. At the time of this writing, our tftproot directory contains 73 files as I have only a few OSes and a few test clients... but by the time we go live, we will have hundreds of files to keep synched between TFTP servers. As we add clients to the network, a minimum of two files are created in the tftproot directory and if they require a special OS, additional files are required.

Is it possible to use a wildcard to map all files to a directory? For example, specify something like "usb1/tftproot/ & filename" for the "Real Filename" field?

Thanks
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TFTP - Set tftp root directory

Tue Aug 14, 2012 4:30 pm

no, it is not possible to add wildcards as real name. however you can leave that empty, as result if req.name will match file with your suggested name will be created

for example
/ip tftp add allow=yes allow-rollover=yes disabled=no ip-addresses="" read-only=no real-filename="" req-filename="aa.\\.bbb"
will create rule that if you upload aaa.bbb, aab.bbb and aac.bbb files will be uplaoded successfully with these names as that will match anything that has aa <any symbol> .bbb
 
vddsd
just joined
Topic Author
Posts: 16
Joined: Wed Jul 04, 2012 1:12 am
Location: NB, Canada

Re: TFTP - Set tftp root directory

Tue Aug 14, 2012 8:07 pm

Thanks again for the reply. I think I may have not have been clear enough in my question as I think you answered a different question all together :)

If I understand your reply, by specifying that filter in the "Req. Filename" field, the router will accept any files starting with aa and ending with bbb. In reality, I'm not worried about security at all and I do not wish to enter any filtering whatsoever.

I'll try to ask my question via examples. In reality, I wish to have the TFTP Server do the following:
1) The user requests file "pxelinux.0". The TFTP server returns the file stored at "usb1/tftproot/pxelinux.cfg"
2) The user requests file "pxelinux.cfg/01-00-08-74-ab-58-0c". The TFTP server returns the file stored at "usb1/tftproot/pxelinux.cfg/01-00-08-74-ab-58-0c".

Essentially all I require is to be able to set the "base path" or the "tftp root" directory of the TFTP server. In other words, I need to "prefix" all filenames with the "root directory".

Thanks,

Shaun
 
artemk
newbie
Posts: 26
Joined: Wed Jun 20, 2012 8:06 pm
Location: Kyiv, Ukraine

Re: TFTP - Set tftp root directory

Wed Aug 22, 2012 9:39 pm

Essentially all I require is to be able to set the "base path" or the "tftp root" directory of the TFTP server. In other words, I need to "prefix" all filenames with the "root directory".
I need exactly the same.

Have anybody sucessfully built TFTP boot server on mikrotik?

This is very easy task for DD-WRT, but it so hard to make it run on mikrotik and this is very sad =(

Does anybody knows if there any way to install custom tftp server on routerOS? Maybe from debian or etc?
 
vddsd
just joined
Topic Author
Posts: 16
Joined: Wed Jul 04, 2012 1:12 am
Location: NB, Canada

Re: TFTP - Set tftp root directory

Thu Aug 23, 2012 1:00 pm

I opened a support ticket with Mikrotik about this missing feature and their support staff basically said that it is currently not possible to specify the tftp root directory and they have no plans to incorporate this basic feature in the foreseeable future. They recommended either using scripting or the API to programmatically create links to the files' location.

With only a few MB of disk space available on the RouterBoards, storing files on the local embedded storage is not a viable option for TFTP. I find it very sad that in its current state that the TFTP server in RouterBoards is crippled to the point that it is not usable.

I'm sure a skilled Mikrotik developer would have this script written in 30 minutes, but my programming skills and my available time are both limited, so after a couple of days in trying to write a script to work around the routers shortcomings, I have given up.

I may have an alternative solution... when I get back at the office today, I'll try to setup a metarouter on the USB drive, and if this works, then setting up a TFTP on that metarouter would have its root storage on the usb drive. I have never ran into a situation where I had to create a metarouter before, so I don't even know if one can be created on external storage. Also, I don't know if there is enough RAM on a RouterBoard to do that. I realize that this solution is not "clean" and its very wasteful in resources, but it's the best I could think of given the situation. I'll report back my results.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TFTP - Set tftp root directory

Thu Aug 23, 2012 1:40 pm

it is not possible to set up metarouter on the external storage.

however in version 6.0 (and in next release) it is going to be possible to set real-filename to hold folder name and tftp will take it as a prefix.

For example, if you now have rule that stats req-filename="" real-filename="" then essentially you can request any file from tftp and if path to the file is correct you will get it, for example, if you require path/to/file then tftp is looking up that path from root dir and hand over the file if it is found.

With new behaviour having req-filename="" real-filename="some/random/dir" tftp will attempt to look up file not in root but in dir with the prefix. If we relate this to previous example, then tftp will look of /some/random/dir/path/to/file and hand it over.

Also note, this can be changed a bit, but functionality in one or another way will be available in version 6

in the mean time for version 5 you will still add new entry for every file you want to request that is not in root dir but stored on some externally attached storage, such as USB flash drive.
 
vddsd
just joined
Topic Author
Posts: 16
Joined: Wed Jul 04, 2012 1:12 am
Location: NB, Canada

Re: TFTP - Set tftp root directory

Thu Aug 23, 2012 4:08 pm

Excellent. Thanks for the update. In that case, I'll try to come up with a temporary solution until version 6 comes out.

Since we're talking about version 6... it may be too early to tell, but since the first beta of version 5 came out in March 2010; the first release candidate for version 5 came out in September 2010 (6 months after) and the first stable release of version 5 came our in March 2011 (12 months after the first beta), is it safe to assume that version 6 will follow the same timeline? If this is the case, we'd be looking at a stable release around April 2013ish?

Thanks