centos7 docker配置防火墙firewalld
docker防火墙使用的是底层iptables,封装后的firewalld默认不生效
如果想要使用firewalld,需要做以下调整:
让firewalld移除DOCKER-USER并新建一个
# Removing DOCKER-USER CHAIN (it won't exist at first)
firewall-cmd --permanent --direct --remove-chain ipv4 filter DOCKER-USER # Flush rules from DOCKER-USER chain (again, these won't exist at first; firewalld seems to remember these even if the chain is gone)
firewall-cmd --permanent --direct --remove-rules ipv4 filter DOCKER-USER # Add the DOCKER-USER chain to firewalld
firewall-cmd --permanent --direct --add-chain ipv4 filter DOCKER-USER
加上你想要的规则,注意reject放在最后
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -i docker0 -j ACCEPT -m comment --comment "allows incoming from docker"
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -i docker0 -o eth0 -j ACCEPT -m comment --comment "allows docker to eth0"
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -m comment --comment "allows docker containers to connect to the outside world"
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -j RETURN -s 172.17.0.0/16 -m comment --comment "allow internal docker communication" ## 你可以直接允許來自特定 IP 的所有流量
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -s 61.222.3.133/32 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter DOCKER-USER 0 -j REJECT --reject-with icmp-host-unreachable -m comment --comment "reject all other traffic"
最后reload,并通过iptables -L确认是否正确生效
firewall-cmd --reload
参考链接:
https://holywhite.com/archives/489
centos7 docker配置防火墙firewalld的更多相关文章
- CentOS7下配置防火墙放过Keepalived
Keepalived是一个轻量级的HA集群解决方案,但开启防火墙后各节点无法感知其它节点的状态,各自都绑定了虚拟IP.网上很多文章讲要配置防火墙放过tcp/112,在CentOS7下是无效的,正确的做 ...
- Centos7 Docker配置TLS认证的远程端口的证书生成教程(shell脚本一键生成)
通过 TLS来进行远程访问 百度百科 - TLS.我们需要在远程 docker 服务器(运行 docker 守护进程的服务器)生成 CA 证书,服务器证书,服务器密钥,然后自签名,再颁发给需要连接远程 ...
- centOS7.0配置防火墙
之前用的iptables来管理的防火墙,后来发现centOS7.0中已经用firewalld取代iptables了,于是与时俱进,停用了iptables. systemctl stop iptable ...
- Centos7 systemctl和防火墙firewalld命令(参考https://www.cnblogs.com/marso/archive/2018/01/06/8214927.html)
一.防火墙的开启.关闭.禁用命令 (1)设置开机启用防火墙:systemctl enable firewalld.service (2)设置开机禁用防火墙:systemctl disable fire ...
- 新装Centos7.2 配置防火墙
1.安装 yum -y install firewalld2.开机启动 systemctl enable firewalld3.设置防火墙规则 systemctl restart firewalld ...
- Ubuntu下使用UFW,以及CentOS7的默认防火墙firewalld
UFW是一个简化版的iptables,基于iptables,配置比iptables简单 默认UFW是关闭状态,即Ubuntu默认打开所有端口,比较危险. 检测状态 ufw status 设置默认状态, ...
- Linux centos7.0 配置防火墙及开放端口
现在防火墙有两种服务1.service firewalld 2.service iptables 一.就firewalld来说查看开放的端口 netstat -anp 查询防火墙状态 servi ...
- CentOS7.3防火墙firewalld简单配置
今天安装了centos7.3, 想用iptables的save功能保存规则的时候发现跟rhel不一样了, 后来度娘说centos用的是firewalld而不是iptables了, 平时工作都是用re ...
- Linux防火墙配置(iptables, firewalld)
netfilter和底层实现 iptables firealld Linux中的防火墙 RHEL中有几种防火墙共存: iptables firewalld ip6tables ebtables 这些软 ...
- CentOS7下Firewall防火墙配置用法详解
官方文档地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide ...
随机推荐
- Java8新特性之-Map
Map一些新方法的具体使用案例 1.getOrDefault:default V getOrDefault(Object key, V defaultValue) package com.qbb.th ...
- pinia状态管理初识
一款官方推荐的,代替vuex的,新的状态管理工具. 官方网: https://pinia.vuejs.org/zh/introduction.html 主要区别: 去除了modules的概念,每个st ...
- Python subprocess 使用(一)
Python subprocess 使用(一) 本文主要讲下 subprocess 的简单使用. 1: 通过subprocess 获取设备信息 import subprocess def get_an ...
- ModuleNotFoundError: No module named '_pytest.resultlog'
新环境运行Python时报错 ModuleNotFoundError: No module named '_pytest.resultlog' 上网查,看到解决方法 https://www.cnbl ...
- 解决 IDEA 报错ERROR:JAVA: 无效的源发行版: 11
解决 IDEA 报错ERROR:JAVA: 无效的源发行版: 11 原因 一般都是创建工程的时候 一路next 默认选择了 Java Version 11, 而本地的jdk版本是 8 解决 File ...
- Python——第四章:匿名函数(lambda 函数)
匿名函数也被称为 lambda 函数 lambda 函数是一种小型.一次性的.可以在一行内定义的匿名函数.它通常用于一些简单的操作,例如传递给高阶函数(接受函数作为参数的函数)或在一行内定义短小的功能 ...
- Ubuntu 命令使用方法
apt-get 用作于deb包 yum作用于tar包(也可以运作于rpm包) 首先用yum list wget检查一下你的虚拟机有没有安装wget,如果安装了下面图中会显示 @dvd ,我的没有安装所 ...
- 【OpenVINO】 使用 OpenVINO CSharp API 部署 PaddleOCR 项目介绍
前言: 在之前的项目中,我们已经使用 OpenVINOTM CSharp API 部署 PaddleOCR 全系列模型,但随着PaddleOCRv4版本发布以及OpenVINO CSharp AP ...
- Solon cloud 常用配置
一.配置示例: solon: app: name: "solon-consul-test" group: "test" solon.cloud.consul: ...
- Nacos 1.2.1 集群搭建(二)MySQL、cluster 配置
三台虚机的IP地址被DHCP重分了一下1.MySQL 配置 先建一个 nacos_config 数据库 将SQL执行(方法很多,选自己喜欢的就行) 2.修改 application.propertie ...