首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在centos8主机iptables复制上运行centos7容器

在centos8主机iptables复制上运行centos7容器
EN

Stack Overflow用户
提问于 2020-12-03 07:06:27
回答 1查看 435关注 0票数 0

在centos8主机上运行centos7容器时。在容器中,向一个链中添加一个iptables规则(例如,筛选表输入链),该规则不仅将被添加到输入链中,还将添加到其他链中(例如输出、前向、甚至PREROUTING、POSTROUTING)。

  1. 在centos7主机

上运行centos8容器

docker run -it --privileged centos:8 sh

  1. 运行时,在容器

中安装iptable

代码语言:javascript
复制
yum install -y iptables

iptables -V

  1. 显示iptables版本

代码语言:javascript
复制
iptables version: v1.8.4 (nf_tables)

iptables -t nat -nvL

  1. 列表当前规则

代码语言:javascript
复制
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
# Warning: iptables-legacy tables present, use iptables-legacy to see them

iptables -I INPUT -i eth0 -j REJECT添加了一个新规则:

iptables -nvL

  1. 列表规则

代码语言:javascript
复制
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
# Warning: iptables-legacy tables present, use iptables-legacy to see them

如果在centos8主机上运行centos8容器,则不会发生这种情况。

EN

回答 1

Stack Overflow用户

发布于 2020-12-03 11:27:32

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65121302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档