zoukankan      html  css  js  c++  java
  • centos7 iptables/firewalld docker open port

    here are multiple "hackish" ways to do it:

        scan kernel logs, as mentioned by Jiri (but you have to do it right after starting the container, otherwise it gets messy);
        check the interface counters (sent/received packets/bytes) in the container, then compare with the interfaces in the host, and find the pair that matches exactly (but with sent and receive directions flipped);
        use an iptables LOG rule.

    The last option is, IMHO, the more reliable one (and the easiest to use), but it's still very hackish. The idea is very simple:

        Add an iptables rule to log e.g. ICMP traffic arriving on the Docker bridge:

        sudo iptables -I INPUT -i docker0 -p icmp -j LOG

        Send a ping to the container you want to identify:

        IPADDR=$(docker inspect -f='{{.NetworkSettings.IPAddress}}' d6ed83a8e282)

        ping -c 1 $IPADDR

        Check kernel logs:

        dmesg | grep $IPADDR

        You will see a line looking like this:

        […] IN=docker0 OUT= PHYSIN=vethv94jPK MAC=fe:2c:7f:2c:ab:3f:42:83:95:74:0b:8f:08:00 SRC=172.17.0.79 …

        If you want to be fancy, just extract PHYSIN=… with awk or sed.

        Remove the iptables logging rule (unless you want to leave it there because you will regularly ping containers to identify them).


       iptables -I INPUT -i docker0 -p tcp --dport 9200  -j ACCEPT

  • 相关阅读:
    绘制程序流程图笔记
    强软弱虚引用
    安全点和安全区域
    垃圾回收算法
    垃圾回收相关算法
    内存访问全过程
    多级页表与快表
    分页
    虚拟内存
    内存分段机制
  • 原文地址:https://www.cnblogs.com/SZLLQ2000/p/7095002.html
Copyright © 2011-2022 走看看