AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 911123
Accepted
halfer
halfer
Asked: 2018-05-08 08:55:24 +0800 CST2018-05-08 08:55:24 +0800 CST 2018-05-08 08:55:24 +0800 CST

如何调试为什么 Pure FTPd 无法绑定到 IP 地址?

  • 772

我正在构建一个 Dockerised 系统,该系统将在 HTTP API 中创建和拆除各种服务器类型,用于集成测试。我通过试验如何同时创建和运行多个 FTP 服务器来启动这个项目。

我想在不同的 IP 地址上运行 FTP 服务器,以便测试可以创建和拆除服务器而不会相互干扰。将来,这应该允许测试在必要时并行化。

在我的 Docker 容器中,我根据这个 Docker Compose 配置设置了各种网络:

version: '2'
services:

  missive-box-of-tricks:
    image: missive-box-of-tricks
    networks:
      network-01:
        aliases:
        - network-01
      network-02:
        aliases:
        - network-02
      network-03:
        aliases:
        - network-03
      network-04:
        aliases:
        - network-04
      network-05:
        aliases:
        - network-05
      (trimmed - there's 10 of these)

networks:
  network-01:
    driver: bridge
  network-02:
    driver: bridge
  network-03:
    driver: bridge
  network-04:
    driver: bridge
  network-05:
    driver: bridge
  (trimmed - there's 10 of these)

这会在容器内产生一组网络(再次修剪):

~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:14:00:02  
          inet addr:172.20.0.2  Bcast:172.20.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3249 (3.1 KiB)  TX bytes:0 (0.0 B)

eth1      Link encap:Ethernet  HWaddr 02:42:AC:16:00:02  
          inet addr:172.22.0.2  Bcast:172.22.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3249 (3.1 KiB)  TX bytes:0 (0.0 B)

eth2      Link encap:Ethernet  HWaddr 02:42:AC:15:00:02  
          inet addr:172.21.0.2  Bcast:172.21.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3249 (3.1 KiB)  TX bytes:0 (0.0 B)

eth3      Link encap:Ethernet  HWaddr 02:42:AC:17:00:02  
          inet addr:172.23.0.2  Bcast:172.23.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3249 (3.1 KiB)  TX bytes:0 (0.0 B)

eth4      Link encap:Ethernet  HWaddr 02:42:AC:18:00:02  
          inet addr:172.24.0.2  Bcast:172.24.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3249 (3.1 KiB)  TX bytes:0 (0.0 B)

网络别名是可解析的,因此我希望 FTP 服务器能够监听network-01等。我使用此命令从容器内部启动服务器:

PUBLIC_HOST=network-01

# -P -Force the specified IP address in reply to a PASV/EPSV/SPSV command
# -S -Connections are accepted on the specified IP and port
# -l -This is the authentication type, in the form "protocol:path"
# -E -Only allow authenticated users (if you wanted anonymous only you would substitute -e).
# -j -If the user doesn't have a home directory create it at first login.
# -R -Disallow the usage of the chmod command.
# -B -Instruct the standalone server to start in the background
# -g -Custom pidfile location (defaults to /var/run/pure-ftpd.pid)
# -d Verbose logging

/usr/sbin/pure-ftpd \
    -S $PUBLIC_HOST \
    -p $MIN_PASV_PORT:$MAX_PASV_PORT \
    -g $PID_FILE \
    -l $USER_DB \
    -d \
    -E \
    -j \
    -R

我已经重置了PID和用户数据库文件,以避免冲突,但实际上即使是单个服务器也不会启动。我收到此错误:

无法启动独立服务器:地址不可用

如果我添加 PASV 声明,我会得到相同的结果:

-P $PUBLIC_HOST \

如果我明确输入 IP 地址,而不是使用环境变量,我也会得到相同的结果。

那么,为什么这个 IP 地址不可用呢?有没有另一种方法可以在 Docker 环境中创建一系列 IP 地址,然后绑定一个 PureFTP 实例来监听一个?

docker
  • 1 1 个回答
  • 651 Views

1 个回答

  • Voted
  1. Best Answer
    halfer
    2018-05-12T10:27:14+08:002018-05-12T10:27:14+08:00

    这解决了。要监听特定的 IPv4 地址,不能只使用裸 IP 地址,并且无法识别冒号的端口分隔符。

    有效的语法使用逗号,如下所示,分别用于默认端口和特定端口:

    -S 192.168.0.42,
    -S 192.168.0.42,8021
    
    • 0

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve