我在 Centos 7.4 上有一个 TFTP 服务器。TFTP 服务器已启动并运行,在尝试访问文件时工作正常,连接到本地主机。但是,如果我尝试从另一台服务器访问 TFTP 服务器,则会超时。
防火墙配置正确并且端口可访问。
猫/etc/xinetd.d/tftp
service tftp {
socket_type = dgram
protocol = udp
port = 69
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4 }
猫/etc/xinetd.conf
defaults
{
log_type = SYSLOG daemon info
log_on_failure = HOST
log_on_success = PID HOST DURATION EXIT
cps = 50 10
instances = 50
per_source = 10
v6only = no
groups = yes
umask = 002
}
includedir /etc/xinetd.d
从同一台机器使用 localhost 进行 TFTP 访问:
[root@tftp-001 ~]# tftp -v localhost -c get dir.txt
Connected to localhost (::1), port 69
getting from localhost:dir.txt to dir.txt [netascii]
Received 11 bytes in 0.0 seconds [3093 bit/s]
使用另一台计算机的 TFTP 访问:
[root@pbx-001 ~]# tftp -v 51.15.xxx.yy -c get dir.txt
Connected to 51.15.xxx.yy (51.15.xxx.yy), port 69
getting from 51.15.xxx.yy:dir.txt to dir.txt [netascii]
Transfer timed out.
尾部-F / var / log /消息从本地主机访问时将显示以下行,但从另一台机器访问时则不显示任何内容。
Oct 21 09:44:55 pbx-001 in.tftpd[11986]: Client ::1 finished dir.txt
我尝试从另一台机器运行端口扫描,看起来该端口可以访问并且开放:
[root@pbx-001 ~]# nmap -sU -p 69 51.15.XXX.YY
Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-21 09:47 UTC
Nmap scan report for ZZZZZZZZZZZZZZZZZZZZZZZZ (51.15.XXX.YY)
Host is up (0.00068s latency).
PORT STATE SERVICE
69/udp open|filtered tftp
Nmap done: 1 IP address (1 host up) scanned in 0.55 seconds
我也尝试关闭防火墙,但仍然存在这个问题。
我需要网络外的任何计算机都可以访问 TFTP 服务器,以便在不同的国家和办事处设置几百台 CISCO 电话。
我可以连接到机器上的 SSH、HTTP 等,这不是问题,这实际上只是一个 TFTP 问题。
编辑1:输出iptables -L -n -v是:[root@tftp-001 ~]# iptables -L -n -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
13425 5433K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
249 14891 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
351 19544 INPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0
351 19544 INPUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
351 19544 INPUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
3 117 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
221 12353 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_direct all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_IN_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_IN_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_OUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_OUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT 14168 packets, 1284K bytes)
pkts bytes target prot opt in out source destination
14168 1284K OUTPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD_IN_ZONES (1 references)
pkts bytes target prot opt in out source destination
0 0 FWDI_public all -- + * 0.0.0.0/0 0.0.0.0/0 [goto]
Chain FORWARD_IN_ZONES_SOURCE (1 references)
pkts bytes target prot opt in out source destination
Chain FORWARD_OUT_ZONES (1 references)
pkts bytes target prot opt in out source destination
0 0 FWDO_public all -- * + 0.0.0.0/0 0.0.0.0/0 [goto]
Chain FORWARD_OUT_ZONES_SOURCE (1 references)
pkts bytes target prot opt in out source destination
Chain FORWARD_direct (1 references)
pkts bytes target prot opt in out source destination
Chain FWDI_public (1 references)
pkts bytes target prot opt in out source destination
0 0 FWDI_public_log all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FWDI_public_deny all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FWDI_public_allow all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
Chain FWDI_public_allow (1 references)
pkts bytes target prot opt in out source destination
Chain FWDI_public_deny (1 references)
pkts bytes target prot opt in out source destination
Chain FWDI_public_log (1 references)
pkts bytes target prot opt in out source destination
Chain FWDO_public (1 references)
pkts bytes target prot opt in out source destination
0 0 FWDO_public_log all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FWDO_public_deny all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FWDO_public_allow all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FWDO_public_allow (1 references)
pkts bytes target prot opt in out source destination
Chain FWDO_public_deny (1 references)
pkts bytes target prot opt in out source destination
Chain FWDO_public_log (1 references)
pkts bytes target prot opt in out source destination
Chain INPUT_ZONES (1 references)
pkts bytes target prot opt in out source destination
351 19544 IN_public all -- + * 0.0.0.0/0 0.0.0.0/0 [goto]
Chain INPUT_ZONES_SOURCE (1 references)
pkts bytes target prot opt in out source destination
Chain INPUT_direct (1 references)
pkts bytes target prot opt in out source destination
Chain IN_public (1 references)
pkts bytes target prot opt in out source destination
351 19544 IN_public_log all -- * * 0.0.0.0/0 0.0.0.0/0
351 19544 IN_public_deny all -- * * 0.0.0.0/0 0.0.0.0/0
351 19544 IN_public_allow all -- * * 0.0.0.0/0 0.0.0.0/0
48 2953 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
Chain IN_public_allow (1 references)
pkts bytes target prot opt in out source destination
77 4004 ACCEPT tcp -- * * [MY_HOME_IP] 0.0.0.0/0 tcp dpt:80 ctstate NEW
2 117 ACCEPT tcp -- * * [MY_HOME_IP] 0.0.0.0/0 tcp dpt:22 ctstate NEW
0 0 ACCEPT udp -- * * [MY_HOME_IP] 0.0.0.0/0 udp dpt:69 ctstate NEW
Chain IN_public_deny (1 references)
pkts bytes target prot opt in out source destination
Chain IN_public_log (1 references)
pkts bytes target prot opt in out source destination
Chain OUTPUT_direct (1 references)
pkts bytes target prot opt in out source destination
[root@tftp-001 ~]#
* 编辑 2 * 我使用“firewall-cmd”作为 GUI,这是输出防火墙命令--zone=public--list-all:
[root@tftp-001 ~]# firewall-cmd --zone=public --list-all
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="[MY_HOME_IP]" port port="80" protocol="tcp" accept
rule family="ipv4" source address="[MY_HOME_IP]" port port="22" protocol="tcp" accept
rule family="ipv4" source address="[MY_HOME_IP]" port port="69" protocol="udp" accept
答案1
目前,您的防火墙规则允许来自服务器本身(环回,通过INPUT
规则 2)和来自79.137.39.26
(通过IN_public_allow
规则 3)的 TFTP(UDP 端口 69)连接。您没有提供您尝试使用的客户端的 IP 地址,但是其他条件相同该 IP 的概率只有四十亿分之一(并且由于该规则上的数据包数为零,因此概率可能甚至小于四十亿分之一)。
尝试添加规则以允许全部TFTP 流量,例如
iptables -I INPUT 1 -p udp --dport 69 -j ACCEPT
看看是否有帮助。
答案2
对于未来的读者:这实际上可能与客户端具有状态防火墙阻止来自 tftp 服务器的响应有关。防火墙不会将响应视为已建立或相关的连接,因此会丢弃/阻止。
答案3
我在 CentOS 7.7 上也遇到了这个问题。
但据我所知,该问题本身似乎与 CentOS 无关。
这个问题在 RHEL tftp-server 5.2-22 发布时出现。恢复到 5.2-13 后问题得到解决。
对于其他人来说,要降级,请使用:
答案4
目录和文件的所有权和权限是什么?
尝试在目录上使用“chmod 777”来查看是否存在权限问题。