歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux下FTP和TFTP服務配置基礎教程

Linux下FTP和TFTP服務配置基礎教程

日期:2017/3/2 9:49:47   编辑:關於Linux

FTP和TFTP是我們經常使用的文件傳輸協議。在Linux中,sftp協議由於其安全性的優點,被作為默認的鏈接協議。但是,一些場合下,我們依然需要使用ftp和tftp協議進行文件傳輸。本篇主要介紹配置方法,供有需要的朋友待查。

1、 環境准備

我們選擇Linux 2.6內核進行測試。

[root@SimpleLinuxUp ~]# uname -r

2.6.18-128.el5

當前OS運行在level 3模式下。

[root@SimpleLinuxUp ~]# grep init /etc/inittab

# inittab This file describes how the INIT process should set up

# 0 – halt (Do NOT set initdefault to this)

# 6 – reboot (Do NOT set initdefault to this)

id:3:initdefault:

# System initialization.

si::sysinit:/etc/rc.d/rc.sysinit

默認情況下,tftp服務器包是安裝上的,而FTP服務器沒有安裝。

[root@SimpleLinuxUp Server]# rpm -qa | grep ftp

tftp-server-0.42-3.1

ftp-0.17-35.el5

lftp-3.5.1-2.fc6

2、TFTP服務器安裝配置

TFTP是一種比較特殊的文件傳輸協議。相對於FTP和目前經常使用的SFTP,TFTP是基於TCP/IP協議簇,用於進行簡單文件傳輸,提供簡單、低開銷的傳輸服務。TFTP的端口設置為69。

相對於常見的FTP,TFTP有兩個比較好的優勢:

ü TFTP基於UDP協議,如果環境中沒有TCP協議,是比較合適的;

ü TFTP執行和代碼占用內存量比較小;

默認情況下,Linux內部是安裝了tftp服務器包的。但是默認是不啟動的。

[root@SimpleLinuxUp ~]# chkconfig –list tftp

tftp off

啟用和禁用tftp服務是通過配置文件/etc/xinetd.d/tftp,將其中參數設置。

[root@SimpleLinuxUp ~]# vi /etc/xinetd.d/tftp

# default: off

# description: The tftp server serves files using the trivial file transfer

# protocol. The tftp protocol is often used to boot diskless

# workstations, download configuration files to network-aware printers,

# and to start the installation process for some operating systems.

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot -c

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

配置文件中,將disable默認值從yes改為no。適當修改server_args參數,主要是其中的tftp根目錄地址。

Tftp服務是不需要單獨啟動的,是作為xinetd服務的一個附屬對象連帶啟動。

[root@SimpleLinuxUp ~]# service xinetd status

xinetd (pid 2194) is running…

[root@SimpleLinuxUp ~]# cd /

[root@SimpleLinuxUp /]# mkdir /tftpboot

mkdir: cannot create directory `/tftpboot’: File exists

[root@SimpleLinuxUp /]# cd /tftpboot/

[root@SimpleLinuxUp tftpboot]# cd ..

[root@SimpleLinuxUp /]# chmod -R 777 /tftpboot/

Copyright © Linux教程網 All Rights Reserved