TFT启动报错
问题
执行命令service tftpd-hpa restart
提示
root@localhost:~# service tftpd-hpa restart
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.
排查
按照提示,执行journalctl -xe
命令查看错误信息
root@localhost:~# journalctl -xe
--
-- A start job for unit tftpd-hpa.service has begun execution.
--
-- The job identifier is 1694.
May 05 15:14:08 localhost tftpd-hpa[3007]: * Starting HPA's tftpd in.tftpd
May 05 15:14:08 localhost in.tftpd[3014]: cannot open IPv6 socket, disable IPv6: Address family not supported by protoc>
May 05 15:14:08 localhost in.tftpd[3014]: Cannot set nonblock flag on socket: Bad file descriptor
May 05 15:14:08 localhost systemd[1]: tftpd-hpa.service: Control process exited, code=exited, status=71/OSERR
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit tftpd-hpa.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 71.
May 05 15:14:08 localhost systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit tftpd-hpa.service has entered the 'failed' state with result 'exit-code'.
May 05 15:14:08 localhost systemd[1]: Failed to start LSB: HPA's tftp server.
-- Subject: A start job for unit tftpd-hpa.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
其中
这两行提示cannot open IPv6 socket, disable IPv6: Address family not supported by protoc
笔者之前确实禁用了WSL的ipv6服务
解决
找到原因了,那么指定tftp不使用ipv6服务
- 使用
vim /etc/default/tftpd-hpa
命令打开tftp的默认配置文件 - 在
TFTP_OPTIONS
参数中添加-4
# /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/home/imx6ull/tftp_dir" TFTP_ADDRESS=":69" TFTP_OPTIONS="-4 -l -c -s"
- 使用
service tftpd-hpa restart
命令重新启动tftp