處理ftp服務器 在重啟后ftp客戶端不能連接訪問的問題


1:環境:centos7

2:當在重啟centos7 linux服務器后,再連接ftp客戶端不能鏈接

image

此時需要檢查以下幾點:

2-1:核查ftp服務是否啟動正常:

  1 [root@localhost ~]# service vsftpd status
  2 Redirecting to /bin/systemctl status  vsftpd.service
  3 ● vsftpd.service - Vsftpd ftp daemon
  4    Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
  5    Active: active (running) since Fri 2017-08-25 09:20:59 CST; 30s ago
  6   Process: 4517 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
  7  Main PID: 4520 (vsftpd)
  8    CGroup: /system.slice/vsftpd.service
  9            └─4520 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
 10 
 11 Aug 25 09:20:59 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
 12 Aug 25 09:20:59 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
 13 

如果是ftp服務沒有啟動起來:則需要執行啟動命令

  1 service vsftpd restart

或者是設置ftp服務開機自動啟動;如何設置請參考《CentOS7 搭建FTP服務器》的“七:解決 linux系統重啟后 用ftp工具無法訪問的問題”的內容

 

 

 

2-2:核查firewall防火牆是否啟動正常:

  1 [root@localhost ~]# systemctl status firewalld.service
  2 ● firewalld.service - firewalld - dynamic firewall daemon
  3    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
  4    Active: active (running) since Fri 2017-08-25 09:00:20 CST; 25min ago
  5      Docs: man:firewalld(1)
  6  Main PID: 803 (firewalld)
  7    CGroup: /system.slice/firewalld.service
  8            └─803 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
  9 
 10 Aug 25 09:00:13 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
 11 Aug 25 09:00:20 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
 12 

如果是firewall 服務沒有啟動起來,則需要手動啟動

  1 [root@localhost ~]# systemctl restart firewalld.service
  2 #並核查下 啟動的端口情況  
  3 [root@localhost ~]# firewall-cmd --zone=public --list-ports
  4 80/tcp 8080/tcp
  5 #如果沒有自己想要的端口,則添加端口,然后在重啟firewall
  6 [root@localhost ~]# firewall-cmd --zone=public --add-port=21/tcp --permanent  
  7 success
  8 [root@localhost ~]# systemctl restart firewalld.service
  9 [root@localhost ~]# firewall-cmd --zone=public --list-ports
 10 21/tcp 80/tcp 8080/tcp
 11 

 

 

 

2-3:核查iptables  的狀態是否啟動正常。

  1 [root@localhost ~]# service iptables status
  2 Redirecting to /bin/systemctl status  iptables.service
  3 ● iptables.service - IPv4 firewall with iptables
  4    Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
  5    Active: inactive (dead)
  6 [root@localhost ~]# 
  7 

如果 沒有正常啟動,則需要手動啟動該服務。

  1 [root@localhost ~]# service iptables restart 
  2 

設置正常開機啟動該服務:

 

  1 [root@localhost ~]# cd /etc/rc.d
  2 [root@localhost rc.d]# ls
  3 init.d  rc0.d  rc1.d  rc2.d  rc3.d  rc4.d  rc5.d  rc6.d  rc.local
  4 [root@localhost rc.d]# cat rc.local 
  5 #!/bin/bash
  6 # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
  7 #
  8 # It is highly advisable to create own systemd services or udev rules
  9 # to run scripts during boot instead of using this file.
 10 #
 11 # In contrast to previous versions due to parallel execution during boot
 12 # this script will NOT be run after all other services.
 13 #
 14 # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
 15 # that this script will be executed during boot.
 16 
 17 touch /var/lock/subsys/local
 18 
 19 
 20 
 21 /etc/init.d/nginx start
 22 [root@localhost rc.d]# vi  rc.local 
 23 

在rc.loal 文件中添加  service iptables restart  確定命令

以下是 紅色標注的內容是 添加的啟動iptables服務的內容

  1 [root@localhost ~]# cd /etc/rc.d/
  2 [root@localhost rc.d]# ls
  3 init.d  rc0.d  rc1.d  rc2.d  rc3.d  rc4.d  rc5.d  rc6.d  rc.local
  4 [root@localhost rc.d]# cat rc.local 
  5 #!/bin/bash
  6 # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
  7 #
  8 # It is highly advisable to create own systemd services or udev rules
  9 # to run scripts during boot instead of using this file.
 10 #
 11 # In contrast to previous versions due to parallel execution during boot
 12 # this script will NOT be run after all other services.
 13 #
 14 # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
 15 # that this script will be executed during boot.
 16 
 17 touch /var/lock/subsys/local
 18 
 19 
 20 #開機默認啟動nginx服務
 21 /etc/init.d/nginx start
 22 #開機重啟 ip 防火牆 
 23 
service iptables restart
 24 [root@localhost rc.d]# 
 25 


 

如果以上3個服務都啟動正常,則ftp客戶端連接應該是正常的。若還有問題,則需要仔細核查

image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM