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

  • 相关阅读:
    Spring IoC容器实现
    Spring IoC简介及使用
    tomcat使用及原理
    tomcat的连接数与线程池
    tomcat配置文件server.xml
    java源码之Comparable和Comparator
    java源码之TreeSet
    25 二叉搜索树与双向链表
    24 复杂链表的复制
    条款04:确定对象被使用前已被初始化
  • 原文地址:https://www.cnblogs.com/SZLLQ2000/p/7095002.html
Copyright © 2011-2022 走看看