ForeverNull的专栏

1、TFTP协议

中文wiki 或者 英文wiki

RFC 1350THE TFTP PROTOCOL (REVISION 2)

2、Mac下配置和启动TFTP1)配置

Mac默认自带TFTP。配置文件位置:/System/Library/LaunchDaemons/tftp.plist。

修改配置文件,去掉如下两行:

<key>Disabled</key><true/>

添加如下配置(可选),就是添加-l选项:

<array><string>/usr/libexec/tftpd</string><string>-i</string><string>-l</string><string>/private/tftpboot</string></array>

简要说明:

I、-i选项,开启不安全模式。-l选项,使用syslog记录所有请求的日志。关于说明请参考:man tftpd(打开终端,输入这条命令就能看到了)。

II、/private/tftpboot是默认路径,需要改变其读写权限(非常重要),执行命令:

chmod -R 777 /private/tftpboot 2)启动sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plistsudo launchctl start com.apple.tftpd

执行上边两条,如果没有报错,那么说明启动成功。如果想看日志可以使用如下命令:

tail -f /var/log/system.log

得到的日志应该如下:

Mar 7 14:04:02 ***.local sudo[589]: *** : TTY=ttys000 ; PWD=/Users/*** ; USER=root ; COMMAND=/bin/launchctl load -F /System/Library/LaunchDaemons/tftp.plistMar 7 14:04:09 ***.local sudo[591]: *** : TTY=ttys000 ; PWD=/Users/*** ; USER=root ; COMMAND=/bin/launchctl start com.apple.tftpdMar 7 14:04:09 ***.local tftpd[593]: recvfrom: Resource temporarily unavailableMar 7 14:04:09 *** com.apple.xpc.launchd[1] (com.apple.tftpd[593]): Service exited with abnormal code: 1

这个位置貌似有一条报错,但是不影响使用,如果有高手请指教如何处理。

3)关闭sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plistsudo launchctl stop com.apple.tftpd3、TFTP协议的使用

在启动TFTP服务器后,我们就可以使用TFTP来连接这台服务器,并获取或者提交文件了。下边用命令行来演示:

***:~ ***$ tftptftp> connect localhosttftp> statusConnected to localhost.Mode: netascii Verbose: off Tracing: offRexmt-interval: 5 seconds, Max-timeout: 25 secondstftp> verboseVerbose mode on.tftp> get 1.txtgetting from localhost:1.txt to 1.txt [netascii]Received 9 bytes in 0.0 seconds [inf bits/sec]tftp> quit

简单说明:我们通过tftp从tftp服务器上获取1.txt(/private/tftpboot/1.txt)文件。

connect host-name [port] 连接服务器。其他命令请参考: man tftp。

4、使用TFTP给TP-Link固件升级

如果上述步骤都已顺利完成,那么用MAC的TFTP给TP-Link升级都很简单了,,只需要到TP-Link官网搜索你的路由器的对应的固件下载,然后将bin文件放到/private/tftpboot目录下,并进入路由器192.168.1.1,然后固件升级,点几下按钮就搞定了。请大家尽情发乎吧。

为你的难过而快乐的是敌人,

ForeverNull的专栏

相关文章:

你感兴趣的文章:

标签云: