Linux怎么安装tftp

Linux怎么安装tftp,第1张

1
查看yum源里是tftp软件包。如果yum没有或不会配置,可参阅另一篇经验如何配置yum。
2
yum安装tftp-server。使用yum直接安装即可。yum会自动查询依赖关系,如图中标出的。
多图
3
安装成功。安装成功,屏幕会输出安装包成功安装,依赖安装了什么包。tftp安装成功后在/etc/xinetdd下生成配置文件
多图
4
修改配置文件。打开配置文件,把disable=yes换成no即可,表示启动tftpd。
5
启动tftp服务。tftp服务托管于xinetd,只要重启xinetd服务即可。重启后可以查看69号端口是否开启。
6
测试tftp。tftpd已经成功启动,你可已上传下载文件,创建一个文本,放在/var/lib/tftpboot/ 目录下,然后用tftp命令连接服务器,get put 文件名即可上传下载。

修改/etc/xinetdd/tftp ,把disabled设置为no,server_args=-s /tftpboot,其中tftpboot为默认目录,你也可以自己修改。你说把/mnt/aaa上传tftpboot目录,完全没必要,我不是太明白你的意思。直接把/mnt/aaa 拷贝到/tftpboot 目录下就可以了。 然后重启tftp服务。/etc/xinetd restart 用tftp下载,比把zImage拷贝到/tftpboot下,板子上电,打开超级终端,假如你的bootloader是UBOOT,板子是2410或者2440,可以:tftp 0x30008000 zImage ,就可以下载了。不懂的话再找我。Q:372687917

FTP和TFTP是我们经常使用的文件传输协议。在Linux中,sftp协议由于其安全性的优点,被作为默认的链接协议。但是,一些场合下,我们依然需要使用ftp和tftp协议进行文件传输。本篇主要介绍配置方法,供有需要的朋友待查。

1、 环境准备

我们选择Linux 26内核进行测试。

[root@SimpleLinuxUp ~]# uname -r
2618-128el5

当前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/rcd/rcsysinit

默认情况下,tftp服务器包是安装上的,而FTP服务器没有安装。

[root@SimpleLinuxUp Server]# rpm -qa | grep ftp
tftp-server-042-31
ftp-017-35el5
lftp-351-2fc6

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/xinetdd/tftp,将其中参数设置。

[root@SimpleLinuxUp ~]# vi /etc/xinetdd/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/intftpd
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/

由于连接使用UDP端口,我们将防火墙和SELinux配置关闭。

[root@SimpleLinuxUp /]# service iptables stop
[root@SimpleLinuxUp /]# service iptables status
Firewall is stopped

对xinetd服务重启,连带将tftp服务启动。

[root@SimpleLinuxUp /]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]

[root@SimpleLinuxUp /]# chkconfig --list tftp
tftp on

使用netstat判断UDP端口开启。

[root@SimpleLinuxUp /]# netstat -nlp | grep udp
udp 0 0 0000:772 0000: 1868/rpcstatd
udp 0 0 0000:775 0000: 1868/rpcstatd
udp 0 0 0000:69 0000: 3869/xinetd
(篇幅原因,有省略……)

从远程服务器启动连接,笔者从windows环境客户端启动。TFTP是可以不输入用户名和密码的,所以对于安全文件传输是不满足的。
C:\Documents and Settings\liuzy>tftp
Transfers files to and from a remote computer running the TFTP service
TFTP [-i] host [GET | PUT] source [destination]

-i Specifies binary image transfer mode (also called
octet) In binary image mode the file is moved
literally, byte by byte Use this mode when
transferring binary files
host Specifies the local or remote host
GET Transfers the file destination on the remote host to
the file source on the local host
PUT Transfers the file source on the local host to
the file destination on the remote host
source Specifies the file to transfer
destination Specifies where to transfer the file

测试客户端与服务器根目录之间的文件互相拷贝传输。

C:\Documents and Settings\liuzy>tftp 1921680100 put cogtrwinini
Transfer successful: 536 bytes in 1 second, 536 bytes/s

[root@SimpleLinuxUp tftpboot]# ls -l
total 12
-rw-rw-rw- 1 nobody nobody 507 Jan 28 10:39 cogtrwinini
drwxrwxrwx 4 root root 4096 Dec 26 09:46 linux-install

D:\>tftp 1921680100 get cogtrwinini
Transfer successful: 536 bytes in 1 second, 536 bytes/s

TFTP是一种简单的文件传输解决方案。

3、FTP配置

目前成熟系统设计中,都将FTP协议和传输定性为非安全传输协议。它和telnet登录方式,逐渐为SFTP和SSH协议所取代。在Linux流行版本中,SFTP已经成为默认配置项目。
在Linux发行版的光盘中,已经包括了vsftp服务器安装包,是需要手工安装。

配置tftp
配置tftp服务的步骤:
1、安装相关软件包:tftpd(服务端),tftp(客户端),xinetd
sudo apt-get install tftpd tftp xinetd
2、建立配置文件
在/etc/xinetdd/下建立一个配置文件tftp
sudo vi tftp
在文件中输入以下内容:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/intftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
保存退出
3、建立tftp服务文件目录(上传文件与下载文件的位置),
并且更改其权限
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R
4、重新启动服务
sudo /etc/initd/xinetd restart
至此tftp服务已经安装完成了,下面可以对其进行一下测试。
(假设在当前目录下有一个测试文件testtxt)
$tftp 127001
tftp> put testtxt
Sent 1018 bytes in 00 seconds
tftp> get testtxt
Received 1018 bytes in 01 seconds
tftp> quit
$
通过get命令,可以把当前目录下的testtxt文件,
通过tftp上传到它的服务文件目录。
这时,在/tftpboot下面会出现testtxt文件。
通过put命令,可以从/tftpboot下,下载testtxt文件。
这样就验证了tftp服务配置的正确性。
当文件上传与下载结束后,可以通过quit命令退出。
严格按照以上步骤配置tftp服务,一般都可以成功。
如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。
配置nfs服务器
在ubuntu下安装、配置nfs服务的步骤如下:
1、安装nfs
Ubuntu上默认是没有安装nfs服务器的,因此我们首先安装nfs服务器端:
$sudo apt-get install nfs-kernel-server
在一些文档中,提出还需要使用apt-get来手动安装nfs的客户端nfs-common,
以及端口映射器portmap,
但其实这是没有必要的,因为在安装nfs-kernel-server时,
apt会自动为我们把它们安装好。
2、配置/etc/exports
nfs允许挂载的目录及权限在文件/etc/exports中进行了定义。
例如,我们要将根目录下的rootfs目录共享出来,
那么我们需要在/etc/exports文件末尾添加如下一行:
/rootfs (rw,sync,no_root_squash)
其中:/rootfs是要共享的目录,
代表允许所有的网络段访问,
rw是可读写权限,
sync是资料同步写入内存和硬盘,
no_root_squash是nfs客户端分享目录使用者的权限,
如果客户端使用的是root用户,那么对于该共享目录而言,
该客户端就具有root权限。
其它nfs常用的参数有:
ro 只读访问
rw 读写访问sync 所有数据在请求时写入共享
async nfs在写入数据前可以响应请求
secure nfs通过1024以下的安全TCP/IP端口发送
insecure nfs通过1024以上的端口发送
wdelay 如果多个用户要写入nfs目录,则归组写入(默认)
no_wdelay 如果多个用户要写入nfs目录,则立即写入,
当使用async时,无需此设置。
hide 在nfs共享目录中不共享其子目录
no_hide 共享nfs目录的子目录
subtree_check 如果共享/usr/bin之类的子目录时,
强制nfs检查父目录的权限(默认)
no_subtree_check 和上面相对,不检查父目录权限
all_squash 共享文件的UID和GID映射匿名用户anonymous,
适合公用目录。
no_all_squash 保留共享文件的UID和GID(默认)
root_squash root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squas root用户具有根目录的完全管理访问权限
anonuid=xxx 指定nfs服务器/etc/passwd文件中匿名用户的UID
anongid=xxx 指定nfs服务器/etc/passwd文件中匿名用户的GID
3、重启服务
$sudo /etc/initd/portmap restart
$sudo /etc/initd/nfs-kernel-server restart
4、测试nfs
此时可以运行以下命令来显示一下共享出来的目录:
$showmount -e
或者可以使用以下命令把它挂载在本地磁盘上,例如将/rootfs挂载到/mnt下:
$ sudo mount -t nfs localhost:/rootfs /mnt
可以运行df命令查看是否挂载成功。查看后可以使用以下命令卸载:
$ sudo umount /mnt

用指令"rpm -qa | grep minicom"来确认是否安装了minicom,回车后会显示minicom 的版本信息
#minicom -s
启动
出现配置菜单:选serial port setup
进入串口配置
输入A配置串口驱动为/dev/ttyS0
输入E配置速率为115200 8N1
输入F将 Hardware Flow Control 设 为 NO
回车 退出

在配置菜单 选Save setup as df1保存(一定要记得这一步)
选Exit退出
下次在输入minicon 即可直接进入。
命令minicom是进入串口超级终端画面,而minicom -s为配置minicom。
说明/dev/ttyS0 对应为串口0 为你连接开发板的端口。
注意:非正常关闭minicom,会在/var/lock下创建几个文件LCK,这几个文件阻止了minicom的运行,将它们删除后即可恢复


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/13495604.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-18
下一篇 2023-08-18

发表评论

登录后才能评论

评论列表(0条)

保存