免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9157 | 回复: 6
打印 上一主题 下一主题

[FTP] vsftp如何同时监听两个端口 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-22 10:47 |只看该作者 |倒序浏览
本来,vsftp 只监听21端口

现在想把2121也设成ftp 的端口,,
即也可以通过2121来连接ftp服务器。

或者说,如果可以启动两个vsftp 服务也可以。那么一个21 一个2121

这个问题有人问过,但是回答不详细,说配置两个.conf文件 但是我启动第二个的时候就提示“500 OOPS: could not bind listening IPv4 socket”
后来又查到资料说做两个进程 一个进程一个.conf文件 在rc.local添加启动 比如:vsftpd /etc/vsftpdlocal.conf 此文件指定的端口为2121 那么原本21端口就起不来了
我想应该是这个程序已经绑定2121端口 所以不能再帮顶21端口

老大们 怎么解决啊

多谢!

论坛徽章:
0
2 [报告]
发表于 2010-01-22 13:31 |只看该作者
端口从定向


iptables -t nat -A POSTROUTING -d ip -p tcp --dport 2121 -j MASQUERADE
iptables -t nat -A PREROUTING -d ip -p tcp --dport 2121 -j DNAT --to ip:21

论坛徽章:
0
3 [报告]
发表于 2010-01-22 14:01 |只看该作者
原帖由 7717060 于 2010-1-22 13:31 发表
端口从定向


iptables -t nat -A POSTROUTING -d ip -p tcp --dport 2121 -j MASQUERADE
iptables -t nat -A PREROUTING -d ip -p tcp --dport 2121 -j DNAT --to ip:21



恩 办法不错 我测试了一下 只设置一条就可以

iptables -t nat -A PREROUTING -p tcp -d 192.168.1.220 --dport 2121 -j DNAT --to 192.168.1.220:21

论坛徽章:
0
4 [报告]
发表于 2010-01-24 02:17 |只看该作者

论坛徽章:
0
5 [报告]
发表于 2011-04-23 23:32 |只看该作者
本帖最后由 pwcpp 于 2011-04-24 11:41 编辑

好像vsftpd在一个ip上不能同时监听2个port,可以在同一台机子上做一个虚拟网卡,然后再针对这个不同的ip监听另一个port,这里有老外的帖子

http://www.centos.org/docs/4/htm ... -VSFTPD-START-MULTI

15.4.1. Starting Multiple Copies of vsftpd

Sometimes one computer is used to serve multiple FTP domains. This is a technique called multihoming. One way to multihome using vsftpd is by running multiple copies of the daemon, each with its own configuration file.

To do this, first assign all relevant IP addresses to network devices or alias network devices on the system. Refer to the chapter titled Network Configuration in Red Hat Enterprise Linux System Administration Guide for more information about configuring network devices and device aliases. Additional information can be found about network configuration scripts in Chapter 8 Network Interfaces.

Next, the DNS server for the FTP domains must be configured to reference the correct machine. If the DNS server is running on Red Hat Enterprise Linux, refer to the chapter titled BIND Configuration in Red Hat Enterprise Linux System Administration Guide for instructions about using the Domain Name Service Configuration Tool (system-config-bind). For information about BIND and its configuration files, refer to Chapter 12 Berkeley Internet Name Domain (BIND).

For vsftpd to answer requests on different IP addresses, multiple copies of the daemon must be running. The first copy must be run using the vsftpd initscripts, as outlined in Section 15.4 Starting and Stopping vsftpd. This copy uses the standard configuration file, /etc/vsftpd/vsftpd.conf.

Each additional FTP site must have a configuration file with a unique name in the /etc/vsftpd/ directory, such as /etc/vsftpd/vsftpd-site-2.conf. Each configuration file must be readable and writable only by root. Within each configuration file for each FTP server listening on an IPv4 network, the following directive must be unique:

listen_address=N.N.N.N

Replace N.N.N.N with the unique IP address for the FTP site being served. If the site is using IPv6, use the listen_address6 directive instead.

Once each additional server has a configuration file, the vsftpd daemon must be launched from a root shell prompt using the following command:

vsftpd /etc/vsftpd/<configuration-file> &

In the above command, replace <configuration-file> with the unique name for the server's configuration file, such as /etc/vsftpd/vsftpd-site-2.conf.

Other directives to consider altering on a per-server basis are:

    *

      anon_root
    *

      local_root
    *

      vsftpd_log_file
    *

      xferlog_file

For a detailed list of directives available within vsftpd's configuration file, refer to Section 15.5 vsftpd Configuration Options.

To configure any additional servers to start automatically at boot time, add the above command to the end of the /etc/rc.local file.

论坛徽章:
0
6 [报告]
发表于 2011-07-05 15:13 |只看该作者
很简单啊,直接复制vsftpd.conf为vsftpd1.conf。在vsftpd1.conf里面把listen_ports改为2121就行。

招聘 : 技术支持/维
论坛徽章:
0
7 [报告]
发表于 2011-07-05 15:55 |只看该作者
上面的方法我很久之前做过,和 ok 的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP