【问题标题】:Blocking traffic to one of the docker service tasks (containers)阻止到 docker 服务任务(容器)之一的流量
【发布时间】:2017-08-15 11:42:44
【问题描述】:

RabbitMQ 服务以 全局模式 部署有 3 个不同的 vm。 我的目标是阻止到 RabbitMQ 服务容器之一的流量。 尝试使用 iptables 来Reproduce RabbitMQ network partition scenario

通过添加 iptables 链

iptables -A DOCKER-INGRESS -d 10.255.0.33 -p tcp --dport amqp -m state --state ESTABLISHED,RELATED -j DROP

RabbitMQ 服务任务容器运行的 2 个 docker 节点上。 10.255.0.33 是来自 swarm 覆盖网络的容器的 ip,取自 docker service inspect 输出。 虽然,流量仍然通过并且网络分区没有被复制。 如何正确阻塞服务容器的流量?

【问题讨论】:

  • 是否有可能(在您的情况下)在不同的网络上拥有三个不同的虚拟机?
  • 是的,有可能

标签: docker rabbitmq docker-swarm iptables network-partitioning


【解决方案1】:

假设您要阻止来自/到由 container_id 标识的容器的流量

步骤 2-3 应该在容器内运行。

1) 进入容器:

docker exec -it --privileged --env http_proxy=proxy_ip container_id bash

--env http_proxy=proxy_ip 如果您可以直接连接到网络并且不在某些(公司)代理后面,则不需要--env http_proxy=proxy_ip

2) 此步骤假定底层映像操作系统是基于 Debian 的。如果它基于 RED-HAT,请使用 yum 软件包安装程序等效命令。如果是其他操作系统系列,请使用相应的包安装程序命令。

安装iptables

apt-get update && apt-get install -y iptables

3) 阻止进出虚拟 ip 为 10.0.0.183 的容器的流量

iptables -A OUTPUT -d 10.0.0.183 -j DROP
iptables -A INPUT -d 10.0.0.183 -j DROP

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    相关资源
    最近更新 更多