$ sudo /etc/init.d/tftpd-hpa start
[....] Starting tftpd-hpa (via systemctl): tftpd-hpa.serviceJob for tftpd-hpa.service failed because the control process exited with error code.
See "systemctl status tftpd-hpa.service" and "journalctl -xe" for details.
failed!
$ systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
Active: failed (Result: exit-code) since Wed 2020-08-05 11:22:06 CST; 7s ago
Docs: man:systemd-sysv-generator(8)
Process: 28487 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=71)
$ sudo journalctl -xe
......
Aug 05 11:22:06 pek-vx-nwk1 sudo[28471]: svc-cmnet : TTY=pts/32 ; PWD=/ ; USER=root ; COMMAND=/etc/init.d/tftpd-hpa start
Aug 05 11:22:06 pek-vx-nwk1 sudo[28471]: pam_unix(sudo:session): session opened for user root by svc-cmnet(uid=0)
Aug 05 11:22:06 pek-vx-nwk1 systemd[1]: Starting LSB: HPA's tftp server...
-- Subject: Unit tftpd-hpa.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit tftpd-hpa.service has begun starting up.
Aug 05 11:22:06 pek-vx-nwk1 tftpd-hpa[28487]: * Starting HPA's tftpd in.tftpd
Aug 05 11:22:06 pek-vx-nwk1 in.tftpd[28509]: cannot bind to local IPv4 socket: Address already in use
Aug 05 11:22:06 pek-vx-nwk1 systemd[1]: tftpd-hpa.service: Control process exited, code=exited status=71
Aug 05 11:22:06 pek-vx-nwk1 systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'.
Aug 05 11:22:06 pek-vx-nwk1 systemd[1]: Failed to start LSB: HPA's tftp server.
-- Subject: Unit tftpd-hpa.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit tftpd-hpa.service has failed.
--
-- The result is RESULT.
Aug 05 11:22:06 pek-vx-nwk1 sudo[28471]: pam_unix(sudo:session): session closed for user root
Aug 05 11:22:41 pek-vx-nwk1 sudo[28550]: svc-cmnet : TTY=pts/32 ; PWD=/ ; USER=root ; COMMAND=/bin/journalctl -xe
Aug 05 11:22:41 pek-vx-nwk1 sudo[28550]: pam_unix(sudo:session): session opened for user root by svc-cmnet(uid=0)
$ sudo netstat -lnp | grep 69
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 35952/java
udp 0 0 0.0.0.0:69 0.0.0.0:* 3192/xinetd
/etc/xinetd.d下是xinet的自动启动的服务,发现包含tftp
$ cd /etc/xinetd.d/
$ ls -l
-rw-r--r-- 1 root root 640 Feb 6 2018 chargen
-rw-r--r-- 1 root root 313 Feb 6 2018 chargen-udp
-rw-r--r-- 1 root root 502 Feb 6 2018 daytime
-rw-r--r-- 1 root root 313 Feb 6 2018 daytime-udp
-rw-r--r-- 1 root root 391 Feb 6 2018 discard
-rw-r--r-- 1 root root 312 Feb 6 2018 discard-udp
-rw-r--r-- 1 root root 422 Feb 6 2018 echo
-rw-r--r-- 1 root root 304 Feb 6 2018 echo-udp
-rw-r--r-- 1 root root 312 Feb 6 2018 servers
-rw-r--r-- 1 root root 314 Feb 6 2018 services
-rwxrwxrwx 1 root root 464 Aug 5 11:12 tftp*
-rw-r--r-- 1 root root 569 Feb 6 2018 time
-rw-r--r-- 1 root root 313 Feb 6 2018 time-udp
将disable设为yes,保存退出
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
# server_args = -s /
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
$ sudo service xinetd restart
$ sudo netstat -lnp | grep 69
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 35952/java
$ sudo /etc/init.d/tftpd-hpa start
[ ok ] Starting tftpd-hpa (via systemctl): tftpd-hpa.service.
发现这个问题是由于tftp download文件失败,从tftpd-hpa 服务配置的tftp根目录位置download文件失败。
$ cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
而xinetd服务自启动的tftp服务中的tftp根目录的位置与tftpd-hpa的配置不一致,导致启动tftpd-hpa服务失败。
问题解决前的xinetd.d/tftp的配置如下:
$ cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
# server_args = -s /
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
$ cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
# server_args = -s /tftpboot
server_args = -s /
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
$ sudo service xinetd start
$ sudo netstat -lnp | grep 69
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 35952/java
udp 0 0 0.0.0.0:69 0.0.0.0:* 19497/xinetd