CentOS7中关闭firewall,并使用iptables管理防火墙
背景描述
在使用Docker时,启用centos7默认的firewall,启动端口映射时,防火墙规则不生效。docker默认使用了iptables防火墙机制。所以需要关闭firewall使用iptables解决。
1.关闭默认的firewall防火墙
systemctl stop firewalld.service 关闭防火墙
systemctl disable firewalld.service 关闭开机启动
2.开启iptables
yum install iptables (根据centOS7的版本和内核,有些版本已经装过,可以跳过此命令)
yum install iptables-services
service iptables restart
chkconfig iptables on或者systemctl enable iptables.service开机自启
3.编辑防火墙文件(开启了21,22,80,3306端口)
vim /etc/sysconfig/iptables # sampleconfiguration for iptables service
# # you can edit thismanually or use system-config-firewall
# # please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
4.添加防火墙命令
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
5.查看本机关于IPTABLES的设置情况
iptables -L -n
CentOS7中关闭firewall,并使用iptables管理防火墙的更多相关文章
- [CENTOS7] [IPTABLES] 卸载Firewall Id安装 IPTABLES及防火墙设置
卸载Firewall ID,重装IPTABLES:先停止服务 systemctl stop firewalldsystemctl mask firewalld yum install iptabl ...
- 003 centos7中关闭防火墙
在centos7中,防火墙有了新的变化.下面是常用的几个命令. 1.查看状态 systemctl status firewalld 2.关闭防火墙 systemctl stop firewalld.s ...
- CentOS7.4 关闭firewall防火墙,改用iptables
1.关闭默认的firewall防火墙 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service ...
- centOS7中Mariadb数据库安装与基本管理
一.Mariadb数据库安装 1. 直接yum源安装 yum -y install mariadb mariadb-serversystemctl start mariadb /启动Mariadb服务 ...
- CentOS7中关闭selinux
在安装Cobbler和Puppet时需要关闭selinux,但是通常情况下载安装完CentOS7后,默认情况下SElinux是启用状态, 如下所示: [csharp] view plaincopy ...
- CentOS7/6 关闭防火墙
CentOS6关闭防火墙使用以下命令, //临时关闭 service iptables stop //禁止开机启动 chkconfig iptables off CentOS7中若使用同样的命令会报错 ...
- centos7 关闭firewall安装iptables并配置
一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...
- centos7关闭默认firewall,启用iptables
CentOS 7.0默认使用"firewall"防火墙 一:关闭firewall1.直接关闭防火墙systemctl stop firewalld.service 2.禁止fire ...
- CentOS7中firewall防火墙详解和配置,.xml服务配置详解
修改防火墙配置文件之前,需要对之前防火墙做好备份 重启防火墙后,需要确认防火墙状态和防火墙规则是否加载,若重启失败或规则加载失败,则所有请求都会被防火墙 1. firewall-cmd --state ...
随机推荐
- LAMP环境跟LNMP环境有什么不同,主要用什么地方
LAMP即Linux+Apache+Mysql/MariaDB+Perl/PHP/Python Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网 ...
- Flex: Holy Grail
Flex:Holy Grail <html> <head> <style type="text/css"> body,div,header,ma ...
- arcgis server 中Web墨卡托投影与WGS-84坐标的转换
arcgis server 中Web墨卡托投影坐标与WGS-84坐标的转换 //经纬度转墨卡托 function lonlat2mercator(lonlat){ var mercator={x:0, ...
- 2017-07-03(VIM ACL权限 )
VIM 底行模式 :w 保存 :q 退出 :! 强制执行 :ls 列出打开的所有文件 :n 进行下一个查询 :15 定位到15行 /xxx 从光标处向下查找xxx出现的位置 ?xxx 从光标处向上查找 ...
- junit4X系列--Builder、Request与JUnitCore
原文出处:http://www.blogjava.net/DLevin/archive/2012/05/12/377957.html.感谢作者的无私分享. 初次用文字的方式记录读源码的过程,不知道怎么 ...
- 流API--流的迭代
虽然流不是数据存储对象,但是仍然可以使用迭代器来遍历其元素,就如同使用迭代器遍历集合中的元素一样. 流API支持2类迭代器,一类是传统的Iterator,另一类是JDK8新增的Spliterator. ...
- 二、Html基本语法
1,XHTML的基本结构和规则 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> < ...
- JSP内置对象值out对象及其它的一些常见方法
out对象: out对象是jspWriter类的实例,是向客户端输出内容常用的对象. 常用方法如下: void println() 向客户端打印字符串 void clear() 清除缓冲区的内容,如果 ...
- Spring 4.x (一)
1 Spring是什么? Spring是一个开源框架 Spring是为简化企业级应用开发而生的,使用Spring可以使得简单的JavaBean能够实现以前只有EJB才能实现的功能. Spring是一个 ...
- 机器学习--kNN算法识别手写字母
本文主要是用kNN算法对字母图片进行特征提取,分类识别.内容如下: kNN算法及相关Python模块介绍 对字母图片进行特征提取 kNN算法实现 kNN算法分析 一.kNN算法介绍 K近邻(kNN,k ...