本文以vsftp为例,介绍如何安装、配置FTP,以及系统防火墙的配置、网络防火墙的配置、映射到公网的配置等。

安装

[[email protected] ~]# yum search vsftp
============ N/S matched: vsftp ==============
vsftpd-sysvinit.x86_64 : SysV initscript for vsftpd daemon
vsftpd.x86_64 : Very Secure Ftp Daemon 
[[email protected] ~]# yum install vsftpd
Installed:
vsftpd.x86_64 0:3.0.2-25.el7

启动

[[email protected] ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address   Foreign Address State  PID/Program name
 tcp        0      0 0.0.0.0:22      0.0.0.0:*       LISTEN 935/sshd            

[[email protected] ~]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
    Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
    Active: inactive (dead)

[[email protected] ~]# systemctl start vsftpd
[[email protected] ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[[email protected] ~]# systemctl status vsftpd 
● vsftpd.service - Vsftpd ftp daemon
    Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
    Active: active (running) since Mon 2018-01-01 00:18:55 CST; 15s ago
  Main PID: 1349 (vsftpd)
    CGroup: /system.slice/vsftpd.service
            └─1349 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Jan 01 00:18:54 centos systemd[1]: Starting Vsftpd ftp daemon…
Jan 01 00:18:55 centos systemd[1]: Started Vsftpd ftp daemon.
[[email protected] ~]# netstat -tunlp          
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address    Foreign Address  State  PID/Program name
 tcp6       0      0 :::21            :::*             LISTEN 349/vsftpd

配置

配置Linux防火墙

如果防火墙没有开放FTP的端口,其它主机无法连接

[[email protected] ~]# telnet 192.168.8.156 21
Trying 192.168.8.156…
telnet: connect to address 192.168.8.156: No route to host

配置网络中的防火墙

将FTP映射到公网

0 Comments

发表评论

电子邮件地址不会被公开。 必填项已用*标注