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 ...
随机推荐
- dedecms 下载时弹出提示登录框或直接下载
http://jingyan.baidu.com/article/9f63fb918656c2c8400f0ebc.html DEDECMS 默认下载 是直接给出了一个 本地下载的 下载链接 本 ...
- git分支小问题
参考网址:http://hbiao68.iteye.com/blog/2055493 1.查看分支 git branch 或者 git branch -v 2.创建一个新的分支 git branch ...
- struts文件异常Included file cannot be found
1.命名规范,都是采用struts-xxx.xml文件,即以struts开头 2.file的路径不要以/开头,在其他版本是以/开头的 <include file="/com/bjsxt ...
- 通读cheerio API ——NodeJs中的jquery
通读cheerio API ——NodeJs中的jquery 所谓工欲善其事,必先利其器,所以通读了cheerio的API,顺便翻译了一遍,有些地方因为知道的比较少,不知道什么意思,保留了英文,希望各 ...
- python 之pulp 线性规划介绍及举例
pulp http://pythonhosted.org/PuLP/main/basic_python_coding.html 供水问题 1问题 供水公司有三个水库分别为A,B,C向四个小区甲乙丙丁供 ...
- Linux cp 移动的时候报错
报错如下: cp: omitting directory `./nginx-1.12.1' 原因: 要移动的目录下还存在有目录 解决: cp -r 文件名 地址 注意: 这里的-r代表递归 ...
- nagios中监测dns 227.7.128.68的网络状态
[root@nhserver2 ~]# cd /usr/local/nagios/etc/objects [root@nhserver2 objects]# vim hosts_dns.cfgdefi ...
- matlab输入输出语句(input、disp、fprintf)
输入语句 输入数值 ?x=input('please input a number:') please input a number:22 x = 22 输入字符串 ?x=input('please ...
- 【转】sed 学习笔记
一 . sed 简介 1 . 功能 sed 是一种流编辑器,所谓流编辑器是指能够对来自文件或者管道的输入流进行基本的文本转换的工具,比方说查找替换删除等. 2 . 最简单的运作机制 sed ...
- Mysql高可用架构(主从同步)
做高可用的优势 1.成本低 2.解决单点故障 3.不容易遇到性能瓶颈 一 .Mysql主从同步架构搭建案例 优点如下:·在业务繁忙阶段,在从服务器上可以执行查询工作(即我们常说的读写分离),降低主服务 ...