歡迎您光臨本站 註冊首頁

vsftp如何同時監聽兩個埠

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

vsftp如何同時監聽兩個埠

本來,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埠

老大們 怎麼解決啊

多謝!
《解決方案》

埠從定向


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
《解決方案》

原帖由 7717060 於 2010-1-22 13:31 發表 http://linux.chinaunix.net/bbs/images/common/back.gif
埠從定向


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
《解決方案》

:mrgreen:
《解決方案》

本帖最後由 pwcpp 於 2011-04-24 11:41 編輯

好像vsftpd在一個ip上不能同時監聽2個port,可以在同一台機子上做一個虛擬網卡,然後再針對這個不同的ip監聽另一個port,這裡有老外的帖子

http://www.centos.org/docs/4/html/rhel-rg-en-4/s1-ftp-vsftpd-start.html#S2-FTP-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.
《解決方案》

很簡單啊,直接複製vsftpd.conf為vsftpd1.conf。在vsftpd1.conf裡面把listen_ports改為2121就行。
《解決方案》

上面的方法我很久之前做過,和 ok 的

[火星人 ] vsftp如何同時監聽兩個埠已經有801次圍觀

http://coctec.com/docs/service/show-post-14360.html