본문 바로가기

Linux

Ubuntu - tftp 설정

$ sudo apt-get install tftp tftpd xinetd


$ sudo vi /etc/xinetd.d/tftp


service tftp

{

    socket_type = dgram

    protocol = udp

    wait = yes

    user = root

    server = /usr/sbin/in.tftpd

    server_args = -s /tftpboot

    disable = no

}


$ sudo mkdir /tftpboot


$ sudo chmod -R 777 /tftpboot


$ sudo chown -R root /tftpboot/


$ sudo /etc/init.d/xinetd restart





=======================================================

TFTPD-HPA (Trivial File Transfer Protocol Server)

Installation

A TFTP server is mainly required for booting operating systems or configurations over the network. The installation is done by:

# apt-get install tftpd-hpa

Server Configuration

The TFTP server can be started by one of two ways:

  1. directly as daemon, or
  2. via inetd.

In the first case, running as daemon, the line starting with tftp in /etc/inetd.conf has to be commented (described here for openbsd-inetd or compatible):

Excerpt: /etc/inetd.conf

#tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

and it has to be enabled in the init script's configuration:

Excerpt: /etc/default/tftpd-hpa

RUN_DAEMON="yes"

In the second case, running via inetd, the line starting with tftp in /etc/inetd.conf has to be uncommented (for Debian's default inet daemon openbsd-inetd):

Excerpt: /etc/inetd.conf

tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

and it has to be disabled in the init script's configuration:

Excerpt: /etc/default/tftpd-hpa

RUN_DAEMON="no"

The root directory from where files can be downloaded by a client defaults to /var/lib/tftpboot. It can be changed to, e.g., to/new/tftp/root, if required:

Excerpt: /etc/default/tftpd-hpa

OPTIONS="-l -s /new/tftp/root"

Files can be put into this directory and downloaded from a client without passing this root directory in its requests.

Finally, restart openbsd-inetd and tftpd-hpa:

# /etc/init.d/openbsd-inetd restart
# /etc/init.d/tftpd-hpa restart

Server Testing

Put a file foo into the root directory of the TFTP server. Install a TFTP client:

# apt-get install tftp

and download the file (not neccessarily as root):

$ tftp server.example.com
tftp> get foo
tftp> q

The file should now exist into your current working directory.

Networking Requirements

Prerequisite: Shorewall In case of a packet filter (Shorewall), you will have to permit access from the clients. The difficulties resulting from changing source/destination ports in TFTP are automatically handled by the netfilter NAT/Conntrack helper modules that are loaded by Shorewall by default.

Excerpt: /etc/shorewall/rules

# TFTP
#
ACCEPT		net		$FW		udp	69
#

and restart the packet filter:

# shorewall restart


openWRT에 직접 관련된 내용은 아니지만, target에서 tftp 서버로 뭔가를 쓰려고 할 때 필요한 설정이다.

- OS : ubuntu
/*
$ uname -a
Linux blhole-desktop 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux
*/
- tftpd : tftpd-hpa
- 설정화일 : /etc/default/tftpd-hpa

- 문제점
  1. 원격지에서 tftp 서버에 화일을 보낼때 기존 화일이름이 있는 화일만 쓸수 있는 문제
  2. 쓰기 권한 문제

* 관련에러

Error code 1: File not found

Error code 0: Permission denied



- 해결방법
설정화일을 아래와 같이 수정한다.


# /etc/default/tftpd-hpa

TFTP_USERNAME="root" 
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure -c -l -v -s"

(TFTP_USERNAME이 문제점2와 관련이 있으며, TFTP_OPTIONS는 문제점1과 관련된다.)

'Linux' 카테고리의 다른 글

cp [옵션]  (0) 2019.01.09
sudo 암호입력 없이 사용  (0) 2017.11.17
Ubuntu - how to hide particular account in the login screen  (0) 2017.07.28
리눅스 SVN 명령어  (0) 2017.06.23
SELinux 설정  (0) 2017.06.17