본문 바로가기

server/linux

[Ubuntu] TFTP 설정

728x90

신규 이미지 공유서버를 신설했는데, 장비에서 계속 timeout 발생. wget으로 다운받다보니 TFTP설정을 깜빡함.

 

1) 패키지 설치

sudo apt-get install xinetd tftp tftpd

 

2) tftp 설정

vi /etc/xinetd.d/tftp

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = nobody
        port                    = 69
        server                  = /usr/sbin/in.tftpd
        server_args             = /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
vi /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create"

 

3) 서비스 재시작

systemctl restart tftpd-hpa.service

 

*) 에러처리

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 Mon 2022-12-05 07:18:03 UTC; 48min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 56308 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=71)

Dec 05 07:18:03 tifront-files-server systemd[1]: Starting LSB: HPA's tftp server...
Dec 05 07:18:03 tifront-files-server tftpd-hpa[56308]:  * Starting HPA's tftpd in.tftpd
Dec 05 07:18:03 tifront-files-server in.tftpd[56315]: cannot bind to local IPv4 socket: Address already in use
Dec 05 07:18:03 tifront-files-server systemd[1]: tftpd-hpa.service: Control process exited, code=exited, status=71/OS>
Dec 05 07:18:03 tifront-files-server systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'.
Dec 05 07:18:03 tifront-files-server systemd[1]: Failed to start LSB: HPA's tftp server.

 

재시작이 안되는걸 확인해보니 69번 포트를 누가 이미 사용하고 있다고 나왔다. netstat으로 찍어보니 설정하다가 꼬인거 같아서 그냥 69번 포트를 다 죽였다.

 

netstat -lnp | grep 69
udp        0      0 0.0.0.0:69              0.0.0.0:*                           36399/xinetd        
udp        0      0 0.0.0.0:69              0.0.0.0:*                           36399/xinetd        
kill 36399
netstat -lnp | grep 69

 

이후 다시 재시작.

systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
     Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
     Active: active (running) since Mon 2022-12-05 08:07:11 UTC; 3s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 56403 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
      Tasks: 1 (limit: 38493)
     Memory: 1.8M
     CGroup: /system.slice/tftpd-hpa.service
             └─56424 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure --create --blocksize=1400 /tftpbo>

Dec 05 08:07:11 tifront-files-server systemd[1]: Starting LSB: HPA's tftp server...
Dec 05 08:07:11 tifront-files-server tftpd-hpa[56403]:  * Starting HPA's tftpd in.tftpd
Dec 05 08:07:11 tifront-files-server tftpd-hpa[56403]:    ...done.
Dec 05 08:07:11 tifront-files-server systemd[1]: Started LSB: HPA's tftp server.

 

728x90