转载自:http://www.z4zr.com/page/1006.html

CentOS7用firewall命令“替代”了iptables。在这里我们需要区分“iptables服务”和“iptables命令”。虽然firewalld是替代提供的防火墙管理iptables服务,但是它仍然使用iptables对内核命令动态通信包过滤。所以它只是iptables服务代替,而不是iptables命令。

如果想使用iptables服务,执行如下命令
```
systemctl stop firewalld
systemctl disable firewalld

yum install iptables-services

touch /etc/sysconfig/iptables
systemctl start iptables
systemctl enable iptables

systemctl stop iptables

touch /etc/sysconfig/ip6tables
systemctl start ip6tables
systemctl enable ip6table
```

vim /etc/sysconfig/iptables

重启iptables

service iptables restart

安装firewalld和firewall-cmd请参考结尾link
检查防火墙状态
firewall-cmd --stat

临时开放ftp服务
firewall-cmd --add-service=ftp
永久开放ftp服务
firewall-cmd --add-service=ftp --permanent
关闭ftp服务
firewall-cmd --remove-service=ftp --permanent
配置防火墙在public区域永久开放http服务
firewall-cmd --permanent --zone=public --add-service=http
加入指定开放端口
firewall-cmd --add-port=1324/tcp

为了让之前的设定生效当然要重启服务咯
systemctl restart firewalld
或者使用下面的命令免去重启服务(防火墙策略配置后重新载入)
firewall-cmd --complete-reload
firewall-cmd --reload (这两句功能相同)

检查ftp服务的21端口是否开放
iptables -L -n | grep 21
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 ctstate NEW

查询ftp服务启用状态
firewall-cmd --query-service ftp

查看当前规则
firewall-cmd --list-all

仅允许部分IP访问本机服务配置
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" \
source address="192.168.0.4/24" service name="http" accept"

仅允许部分IP访问本机端口配置
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" \
source address="192.168.0.4/24" \
port protocol="tcp" port="8080" accept"

firewall-cmd --zone=public --add-port=3306/tcp --permanent

输入命令,开通端口报错,

FirewallD is not running

开启防火墙即可。

systemctl start firewalld

Linux Centos 开启防火墙 FirewallD is not running的更多相关文章

  1. Linux CentOS中防火墙的关闭及开启端口

    注:CentOS7之前用来管理防火墙的工具是iptable,7之后使用的是Firewall 样例:在CentOS7上安装tomcat后,在linux本机上可以访问tomcat主页,http://ip: ...

  2. Centos 7 防火墙firewalld命令

    今天自己在Hyper-v下搭建三台Linux服务器集群,用于学习ELKstack(即大数据日志解决技术栈Elasticsearch,Logstash,Kibana的简称),下载的Linux版本为cen ...

  3. CentOS 开启防火墙 firewall ,mysql 远程访问

    最近在阿里云服务器centos上安装了mysql数据库,默认是不开启远端访问功能,需要设置一下防火墙,在开放默认端口号 3306时提示FirewallD is not running,经过排查发现是防 ...

  4. Linux centos修改防火墙为iptables

    防火墙配置 CentOS 7默认使用的是firewall作为防火墙,这里改为iptables防火墙.  firewall操作: # service firewalld status; #查看防火墙状态 ...

  5. Centos 7防火墙firewalld开放80端口(转)

    开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 出现success表明添加成功 命令含义: --zone #作用域 -- ...

  6. centos开启防火墙端口

    1. 查看已打开的端口 # netstat -anp 2. 查看想开的端口是否已开 # firewall-cmd --query-port=80/tcp 若此提示 FirewallD is not r ...

  7. Linux关闭开启防火墙命令

    在外部访问CentOS中部署应用时,需要关闭防火墙. 关闭防火墙命令:systemctl stop firewalld.service 开启防火墙:systemctl start firewalld. ...

  8. (9)centos下防火墙firewalld设置

    学习apache安装的时候需要打开80端口,由于centos 7版本以后默认使用firewalld后,网上关于iptables的设置方法已经不管用了,想着反正iptable也不会用,索性直接搬官方文档 ...

  9. linux centos 7 防火墙相关

    centos 7 系统 默认是开启防火墙,而且没有打开80和8080等端口. 因此,今天配置tomcat和nginx后,分别无法正常访问 访问80和8080端口都报:502错误.(错误的网关)查询资料 ...

随机推荐

  1. mongodb查询实练

    1.mongodb中如何查询 (a=1 or b=2) and (c=3 or d=4)//格式:db.collection.find({"$and":[{第一个条件},{第二个条 ...

  2. [svc]ssh生成key不交互

    ssh-keygen -t rsa -f ~/.ssh/id_rsa -P "" 首次执行不交互 第二次再次执行会让输入y

  3. IOS 获取设备屏幕的尺寸

    // 不包含状态栏 CGRect rect1 = [UIScreen mainScreen].applicationFrame; // 包含状态栏(整个屏幕) CGRect rect2 = [[UIS ...

  4. Objective-C的内存管理(一)黄金法则的理解

    转自:http://blog.csdn.net/lonelyroamer/article/details/7666851 一.内存管理黄金法则: The basic rule to apple is ...

  5. sh 不显示当前的路径

    linux中sh是链接到bash上的,所以sh与bash在功能上是没有区别的 只是sh不显示路径!!! sh-4.1# cd /usr/local/src sh-4.1# pwd /usr/local ...

  6. 线程相关函数(6)-pthread_cond_wait(),pthread_cond_signal(), 条件变量

    pthread_cond_tpthread_cond_initpthread_cond_destroypthread_cond_waitpthread_cond_timedwaitpthread_co ...

  7. JAVA List 分割

    按指定大小,分隔集合,将集合按规定个数分为n个部分 import java.util.ArrayList; import java.util.Collections; import java.util ...

  8. 将多个文件夹内的txt合并

    import os import re def text_create(name): """ 创建txt文件夹 """ desktop_pa ...

  9. RFID Hacking–资源大合集

    原文: http://www.freebuf.com/news/others/605.html http://www.proxmark.org/forum/index.php RFID破解神器官方论坛 ...

  10. vector--C++ STL 学习

    vector对应的数据结构为数组,而且是动态数组,也就是说我们不必关心该数组事先定义的容量是多少,它的大小会动态增长.与数组类似的是,我们可以在末尾进行元素的添加和删除,也可以进行元素值的随机访问和修 ...