# How to log tftp-hpa



## balanga (Nov 18, 2021)

I'm trying to flash a TP-LINK router using this guide:-









						TP-Link Archer MR200 v1
					

TP-Link Archer MR200 v1  AC750 Wireless Dual Band Router with an integrated LTE 150Mbps modem (similar to TP-Link M7350 V1). Comes with 4 100Mbps ethernet ports, one can be used as WAN.  [Archer MR200 v1]  Supported Versions  Hardware Highlights  Firmware  Flash Layout




					openwrt.org
				




I tried FreeBSD's built in tftpd but that didn't work so I've installed ftp/tftp-hpa using this guide:-


			tftp-hpa – BSD derived TFTP Server – BSDSRV.se
		


(not the easiest pkg to install)

but still can't make it work.

Is there any way of creating a log to show that the router has at least attempted to access my tftp server? I've looked at how to enable logging and the only thing I can think of is to add '--verbose' to tftpd-flags  in /etc/rc.conf.
There is also a '--verbosity x' option available but I don't what levels are available.

If I can enable logging should I be able to see what time an attempt was made to access the server, and from where.
And where should I expect to find such a log? /var/log/messages?


----------



## balanga (Nov 18, 2021)

An explanation of verbosity level can be found here:-









						How does the tftpd-hpa --verbosity option work?
					

I'm trying to set up a TFTP server using tftp-hpa, and according to the manpage I can use the --verbosity option to get more output.  Unfortunately I can't find anything that explains what I should...




					unix.stackexchange.com


----------



## SirDice (Nov 18, 2021)

balanga said:


> I tried FreeBSD's built in tftpd but that didn't work


Why didn't that work? And _what_ exactly didn't work?


----------



## balanga (Nov 18, 2021)

SirDice said:


> Why didn't that work? And _what_ exactly didn't work?


How can I tell why it didn't work when I can't find a log?

All I can say is that the router didn't get flashed. It maybe that I didn't press the buttons at exactly the right moment to trigger flashing, it could be that the router couldn't find the tftp server and it couldn't find the correct file or maybe something else. Without a log it's just guesswork.


----------



## covacat (Nov 18, 2021)

you can always tcpdump -i lan0 -nl  port 69 and udp
replace lan0 with your lan interface name


----------



## yetoo (Nov 18, 2021)

balanga said:


> How can I tell why it didn't work when I can't find a log?
> 
> All I can say is that the router didn't get flashed. It maybe that I didn't press the buttons at exactly the right moment to trigger flashing, it could be that the router couldn't find the tftp server and it couldn't find the correct file or maybe something else. Without a log it's just guesswork.


From the tftpd man page:


> *-l*         Log all requests using syslog(3) with the facility    of LOG_FTP.
> *Note*: Logging of LOG_FTP messages must also be enabled in the
> syslog configuration file,    syslog.conf(5).



Remove any tftpd/tftp entries you made in rc.conf and follow https://wiki.freebsd.org/PXE:TFTPd Setup but go to /etc/inted.conf. Uncommenting the tftp line mentioned in the guide also starts logging since -l option is in command argument section. I think it should log to /var/log/messages by default, but I may be wrong on that.


----------



## SirDice (Nov 19, 2021)

Yes, you can have the access logged. But it's not going to log anything if the device doesn't even try to fetch the file. So I would at least verify with tcpdump(1) if you can see the TFTP request. If there's no request at all then the device just isn't being triggered properly.

You often need to do this on a separate network:

```
At that point, the bootloaders integrated tftp client with the ip address of 192.168.1.1, tries to connect to a tftp server running at address 192.168.0.66 and getting the file named ArcherC2V1_tp_recovery.bin
```
That means the TFTP server has to be running on 192.168.0.66, the device itself apparently defaults to 192.168.1.1 in this mode. So it's probably best if you do this on a 'stand-alone' network with the TFTP server specifically configured with IP 192.168.0.66.


----------

