Linux-CentOS6.7——安装tftp服务器
2016-10-15 19:30
253 查看
1.tftp简介
TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。由于只进行小文件传输的,因此不具有FTP的许多功能,比如,只能从文件服务器上获得或写入文件,不能列出目录,不进行认证等等。
对于技术人员,特别是嵌入式开发人员或者需要通过TFTP升级固件的IT人员,可能会经常用到TFTP。
2.tftp的安装
首先确认系统上是否安装了tftp软件包:
[tangbin@localhost ~]$ rpm -qa | grep tftp
tftp-server-0.49-7.el6.x86_64
若未安装,使用sudo yum install -y tftp-server进行安装。
3.配置tftp
tftp的配置文件在/etc/xinetd.d/tftp下:
[tangbin@localhost ~]$ sudo vim /etc/xinetd.d/tftp
[sudo] password for tangbin:
# default: off
# description: The tftp server serves files using thetrivial file transfer \
# protocol. The tftp protocol isoften used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and tostart the installation process for some operating systems.
service tftp
{
disable = no #加入这一项
socket_type = dgram
protocol = udp
wait = yes
user = root
server =/usr/sbin/in.tftpd
server_args = -s /tftp-c #修改这一项,这里-s指tftp服务器的根目录,-c指能创建文件
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
4.开启xinetd服务
[tangbin@localhost ~]$ sudo service xinetd restart
[sudo] password for tangbin:
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
使用netstat命令查看69端口:
[root@localhost tangbin]# netstat -nlp | grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 5745/xinetd
unix 2 [ ACC ] STREAM LISTENING 21057 3269/nautilus/tmp/orbit-tangbin/linc-cc5-0-ebc26e628dca
5.SeLinux策略修改
SeLinux保持开启状态的话,系统有可能会阻止tftp客户端的下载,可以将它暂时关闭:
[tangbin@localhost ~]$ sudo setenforce 0
#这里0表示设置SeLinux为permissive模式,1代表设置SeLinux为enforcing模式
可以使用getenforce 命令查看SeLinux状态:
[tangbin@localhost ~]$ getenforce
Permissive
如果想彻底禁用SeLinux,修改其配置文件将它禁用:
[tangbin@localhost ~]$ sudo vim /etc/sysconfig/selinux
[sudo] password for tangbin:
# This file controls the state of SELinux on thesystem.
# SELINUX= can take one of these three values:
# enforcing- SELinux security policy is enforced.
# permissive- SELinux prints warnings instead of enforcing.
# disabled -No SELinux policy is loaded.
SELINUX=disabled #此处设置为disabled即可
# SELINUXTYPE= can take one of these two values:
# targeted -Targeted processes are protected,
# mls -Multi Level Security protection.
SELINUXTYPE=targeted
6.防火墙策略修改
系统开启了防火墙也有可能会阻止tftp客户端的下载,我们可以在防火墙规则中使能tftp,只需要使能tftp所使用的69端口即可。
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 69 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -pudp --dport 69 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 80 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 21 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 22 -j ACCEPT
保存:
[tangbin@localhost ~]$ sudo /etc/rc.d/init.d/iptablessave
iptables: Saving firewall rules to/etc/sysconfig/iptables:[ OK ]
重启防火墙:
[tangbin@localhost ~]$ sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
查看防火墙状态:
[tangbin@localhost ~]$ sudo service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
4 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:69
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:69
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
也可使用sudo serviceiptables stop关闭防火墙。
如果希望在系统启动时防火墙不启动,我们可以用ntsysv关闭防火墙服务,同时还可以设置tftp服务在系统启动时就开启:
[tangbin@localhost ~]$ sudo ntsysv
[ ] ip6tables
[ ] iptables
[*] tftp
[*] xinetd
7.tftp命令下载测试
首先在/tftp/创建一个待测文件tt.txt:
[tangbin@localhost ~]$ cd /tftp/
[tangbin@localhost tftp]$ sudo touch tt.txt
[tangbin@localhost tftp]$ ls
tt.txt
接着安装busybox里的tftp客户端命令:
[tangbin@localhost ~]$ wget http://www.busybox.net/downloads/busybox-1.19.3.tar.bz2 [tangbin@localhost ~]$ tar -xjf busybox-1.19.3.tar.bz2
[tangbin@localhost ~]$ cd busybox-1.19.3
[tangbin@localhost busybox-1.19.3]$ export TERM=vt100
[tangbin@localhost busybox-1.19.3]$ sudo makemenuconfig
#不要做任何修改直接写保存退出。
[tangbin@localhost busybox-1.19.3]$ make
[tangbin@localhost busybox-1.19.3]$ file busybox
busybox: ELF 64-bit LSB executable, x86-64, version 1(SYSV), dynamically linked (uses shared libs), stripped
[tangbin@localhost busybox-1.19.3]$ sudo cp busybox/usr/local/bin/
[tangbin@localhost busybox-1.19.3]$ cd
[tangbin@localhost ~]$ cd /usr/local/bin/
[tangbin@localhost bin]$ sudo ln -s busybox tftp
[sudo] password for tangbin:
使用busybox里的tftp命令测试:
[tangbin@localhost ~]$ tftp -gr tt.txt 192.168.1.115
[tangbin@localhost ~]$ ls tt.txt
tt.txt
#显示已经下载该文件
8.可能遇到的问题及解决
·在进行make menuconfig 出错,解决方法是安装ncurses库:sudo yum install ncurses-devel。ncurses库是字符终端下屏幕控制的基本库。
·出现Your display is toosmall to run Menuconfig!提示。只需要将你的终端窗口最大化或者把命令行的字体缩小即可。
TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。由于只进行小文件传输的,因此不具有FTP的许多功能,比如,只能从文件服务器上获得或写入文件,不能列出目录,不进行认证等等。
对于技术人员,特别是嵌入式开发人员或者需要通过TFTP升级固件的IT人员,可能会经常用到TFTP。
2.tftp的安装
首先确认系统上是否安装了tftp软件包:
[tangbin@localhost ~]$ rpm -qa | grep tftp
tftp-server-0.49-7.el6.x86_64
若未安装,使用sudo yum install -y tftp-server进行安装。
3.配置tftp
tftp的配置文件在/etc/xinetd.d/tftp下:
[tangbin@localhost ~]$ sudo vim /etc/xinetd.d/tftp
[sudo] password for tangbin:
# default: off
# description: The tftp server serves files using thetrivial file transfer \
# protocol. The tftp protocol isoften used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and tostart the installation process for some operating systems.
service tftp
{
disable = no #加入这一项
socket_type = dgram
protocol = udp
wait = yes
user = root
server =/usr/sbin/in.tftpd
server_args = -s /tftp-c #修改这一项,这里-s指tftp服务器的根目录,-c指能创建文件
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
4.开启xinetd服务
[tangbin@localhost ~]$ sudo service xinetd restart
[sudo] password for tangbin:
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
使用netstat命令查看69端口:
[root@localhost tangbin]# netstat -nlp | grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 5745/xinetd
unix 2 [ ACC ] STREAM LISTENING 21057 3269/nautilus/tmp/orbit-tangbin/linc-cc5-0-ebc26e628dca
5.SeLinux策略修改
SeLinux保持开启状态的话,系统有可能会阻止tftp客户端的下载,可以将它暂时关闭:
[tangbin@localhost ~]$ sudo setenforce 0
#这里0表示设置SeLinux为permissive模式,1代表设置SeLinux为enforcing模式
可以使用getenforce 命令查看SeLinux状态:
[tangbin@localhost ~]$ getenforce
Permissive
如果想彻底禁用SeLinux,修改其配置文件将它禁用:
[tangbin@localhost ~]$ sudo vim /etc/sysconfig/selinux
[sudo] password for tangbin:
# This file controls the state of SELinux on thesystem.
# SELINUX= can take one of these three values:
# enforcing- SELinux security policy is enforced.
# permissive- SELinux prints warnings instead of enforcing.
# disabled -No SELinux policy is loaded.
SELINUX=disabled #此处设置为disabled即可
# SELINUXTYPE= can take one of these two values:
# targeted -Targeted processes are protected,
# mls -Multi Level Security protection.
SELINUXTYPE=targeted
6.防火墙策略修改
系统开启了防火墙也有可能会阻止tftp客户端的下载,我们可以在防火墙规则中使能tftp,只需要使能tftp所使用的69端口即可。
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 69 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -pudp --dport 69 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 80 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 21 -j ACCEPT
[tangbin@localhost ~]$ sudo /sbin/iptables -I INPUT -ptcp --dport 22 -j ACCEPT
保存:
[tangbin@localhost ~]$ sudo /etc/rc.d/init.d/iptablessave
iptables: Saving firewall rules to/etc/sysconfig/iptables:[ OK ]
重启防火墙:
[tangbin@localhost ~]$ sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
查看防火墙状态:
[tangbin@localhost ~]$ sudo service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
4 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:69
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:69
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
也可使用sudo serviceiptables stop关闭防火墙。
如果希望在系统启动时防火墙不启动,我们可以用ntsysv关闭防火墙服务,同时还可以设置tftp服务在系统启动时就开启:
[tangbin@localhost ~]$ sudo ntsysv
[ ] ip6tables
[ ] iptables
[*] tftp
[*] xinetd
7.tftp命令下载测试
首先在/tftp/创建一个待测文件tt.txt:
[tangbin@localhost ~]$ cd /tftp/
[tangbin@localhost tftp]$ sudo touch tt.txt
[tangbin@localhost tftp]$ ls
tt.txt
接着安装busybox里的tftp客户端命令:
[tangbin@localhost ~]$ wget http://www.busybox.net/downloads/busybox-1.19.3.tar.bz2 [tangbin@localhost ~]$ tar -xjf busybox-1.19.3.tar.bz2
[tangbin@localhost ~]$ cd busybox-1.19.3
[tangbin@localhost busybox-1.19.3]$ export TERM=vt100
[tangbin@localhost busybox-1.19.3]$ sudo makemenuconfig
#不要做任何修改直接写保存退出。
[tangbin@localhost busybox-1.19.3]$ make
[tangbin@localhost busybox-1.19.3]$ file busybox
busybox: ELF 64-bit LSB executable, x86-64, version 1(SYSV), dynamically linked (uses shared libs), stripped
[tangbin@localhost busybox-1.19.3]$ sudo cp busybox/usr/local/bin/
[tangbin@localhost busybox-1.19.3]$ cd
[tangbin@localhost ~]$ cd /usr/local/bin/
[tangbin@localhost bin]$ sudo ln -s busybox tftp
[sudo] password for tangbin:
使用busybox里的tftp命令测试:
[tangbin@localhost ~]$ tftp -gr tt.txt 192.168.1.115
[tangbin@localhost ~]$ ls tt.txt
tt.txt
#显示已经下载该文件
8.可能遇到的问题及解决
·在进行make menuconfig 出错,解决方法是安装ncurses库:sudo yum install ncurses-devel。ncurses库是字符终端下屏幕控制的基本库。
·出现Your display is toosmall to run Menuconfig!提示。只需要将你的终端窗口最大化或者把命令行的字体缩小即可。
相关文章推荐
- linux下网路启动服务器安装和配置方法(pxe+tftp+dhcpd)
- 【转】Linux(CentOS)服务器上安装Webmin
- linux系统上tftp服务器的安装配置
- Linux TFTP 服务器安装与配置(转载)
- [centos6.2] 使用dnsmasq 代替 tftp 和 dhcp服务器 作无人职守安装
- RedHat Enterprise Linux 5 安装TFTP服务器和NFS服务器
- RedHat Enterprise Linux 5 安装TFTP服务器和NFS服务器
- Linux 安装TFTP服务器
- RedHat Enterprise Linux 5 安装TFTP服务器和NFS服务器
- Linux(CentOS)服务器上安装Webmin
- Kickstart+NFS+DHCP+TFTP+PXElinux实现CentOS的网络自动安装
- Fedora搭建服务器,DHCP+TFTP+FTP+PXE启动安装CentOS
- RedHat Enterprise Linux 5 安装TFTP服务器和NFS服务器
- linux下网路启动服务器安装和配置方法(pxe+tftp+dhcpd)
- Fedora搭建服务器,DHCP+TFTP+FTP+PXE启动安装CentOS
- Kickstart+NFS+DHCP+TFTP+PXElinux实现CentOS的网络自动安装
- Linux TFTP 服务器安装与配置
- Linux CentOS6.3安装配置vsftpd服务器详解
- CentOS release 5.4 (Final) Linux在HP服务器安装
- PHP web服务器终极解决方案:CentOS v6.x Minimal 32bit + LNAMP 一键安装包【Linux+Nginx+Apache+MySQL+PHP+phpMyAdmin】