萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 伺服器教學

Linux TFTP 伺服器快速架設與配置教學

TFTP 服務安裝

檢查是否已安裝

netstat -a | grep tftp
# 已安裝顯示:udp 0 0 *:tftp *:*

RPM 套件安裝(RHEL/CentOS)

# 從安裝光盤 Servers 目錄安裝
rpm -ivh tftp-server-0.42-3.1.i386.rpm

建立工作目錄

mkdir /tftpboot

服務配置

編輯 xinetd 配置

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
    per_source = 11
    cps = 100 2
    flags = IPv4
}

關鍵參數說明:

  • server_args = -s /tftpboot:指定根目錄(安全模式,限制存取範圍)
  • disable = no:啟用服務(預設可能為 yes)

服務啟動與驗證

# 啟動 xinetd 超級守護進程
/etc/init.d/xinetd start

# 驗證監聽埠
netstat -a | grep tftp
# 成功顯示:udp 0 0 *:tftp *:*

常見用途與安全建議

  • 網路開機:PXE 無盤啟動、嵌入式設備韌體更新
  • 配置備份:網路設備(交換機/路由器)配置檔備份
  • 安全強化:
    • 僅允許特定 IP 存取(配合 TCP Wrappers 或 iptables)
    • 採用唯讀模式(server_args = -s -r /tftpboot)
    • 定期稽核傳輸日誌

故障排除

  • 防火牆阻擋 UDP 69 埠:iptables -A INPUT -p udp --dport 69 -j ACCEPT
  • SELinux 限制:setsebool -P tftp_anon_write on(需寫入權限時)
  • 目錄權限:確保 /tftpboot 可被 tftp 進程讀寫
copyright © 萬盛學電腦網 all rights reserved