虚拟机Ubuntu搭建一个tftp服务器给开发板下载固件,主要设置虚拟机为桥接网络,网线连接开发板网口,刚设好tftp可以用,但是重启电脑后发现tftp用不了,尝试 restart tftp server 却总是报以下错误
root@whost:~# service tftpd-hpa start
Job for tftpd-hpa.service failed because the control process exited with error code. See "systemctl status tftpd-hpa.service" and "journalctl -xe" for details.
根据提示 systemctl status tftpd-hpa.service 查一下错误
root@whost:~# systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since 五 2020-08-21 14:38:10 CST; 10s ago
Docs: man:systemd-sysv-generator(8)
Process: 3530 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=71)
8月 21 14:38:10 whost systemd[1]: Starting LSB: HPA's tftp server...
8月 21 14:38:10 whost tftpd-hpa[3530]: * Starting HPA's tftpd in.tftpd
8月 21 14:38:10 whost systemd[1]: tftpd-hpa.service: Control process exited, code=exited status=71
8月 21 14:38:10 whost systemd[1]: Failed to start LSB: HPA's tftp server.
8月 21 14:38:10 whost systemd[1]: tftpd-hpa.service: Unit entered failed state.
8月 21 14:38:10 whost systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'.
网上查不到tftp 启动失败的文章,怀疑服务器端口问题,于是自己动手翻查配置文本
root@whost:~# vim /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot/images" #下位机的下载目录
TFTP_ADDRESS="192.168.1.156:69" #服务器地址:端口
TFTP_OPTIONS="--secure"
随机改一个端口然后发现依然不行
考虑到问题是每次重启用不了,我的Ubuntu没有设置静态IP,可能重启后Ubuntu动态获取ip后和配置为 tftp server ip不一样,ifconfig一下
inet 地址:192.168.1.156 广播:192.168.1.255 掩码:255.255.255.0
将 /etc/default/tftpd-hpa 中服务器ip更新为ifconfig中的ip,再次 service tftpd-hpa start 成功启动tftp