Centos防火墙的配置
Selinux的三种模式:enforcing,passive,disable
临时更改模式:setengorce 1|0 1:enforcing, 0:passive
[root@Centos7-Server html]#
[root@Centos7-Server html]# setenforce
[root@Centos7-Server html]# getenforce
Permissive
[root@Centos7-Server html]#
[root@Centos7-Server html]# setenforce
[root@Centos7-Server html]# getenforce
Enforcing
[root@Centos7-Server html]#
查询当前seLinux模式:getenforce
[root@Centos7-Server html]#
[root@Centos7-Server html]# getenforce
Enforcing
[root@Centos7-Server html]#
[root@Centos7-Server html]#
selinux 的服务是firewalld。
防火墙的预定义区域:
public:只允许访问本机的某几种服务,如ping,dhcp,ssh等。
block:阻塞所有来访的请求
drop:将所有来访的请求数据包丢弃。
trusted:允许所有的访问请求。
查看默认区域:
[root@Centos7-Server html]# firewall-cmd --get-default-zone
public
[root@Centos7-Server html]#
修改默认区域:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --set-default-zone=trusted
success
[root@Centos7-Server html]# firewall-cmd --get-default-zone
trusted
[root@Centos7-Server html]#
查看区域详细信息:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
向区域中添加服务:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --add-service=dns
success
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http dns
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
重新加载防火墙的配置:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --reload
success
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
永久配置防火墙策略:--permanent这个选项的作用是永久配置防火墙,配置后需要重新加载防火墙配置文件才能生效。
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --permanent --zone=public --add-service=ftpsuccess
[root@Centos7-Server html]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]# firewall-cmd --reload
success
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
端口重定向:
服务器将访问端口转换成另一个端口,如:192。168.0.50:5324 --》192.168.0.50:80通过5324端口访问网页。
[root@Centos7-Server ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=:proto=tcp:toport=
success
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]# firewall-cmd --reload
success
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports: port=:proto=tcp:toport=:toaddr=
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
Centos防火墙的配置的更多相关文章
- centos防火墙端口配置
增加防火墙配置,允许8080端口: # vi /etc/sysconfig/iptables 在允许ssh的下面增加一条: -A INPUT -m state --state NEW -m tcp - ...
- CentOS防火墙iptables的配置方法详解
CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Linux ...
- CentOS 7 防火墙端口配置
CentOS 7 防火墙端口配置查看防火墙是否开启systemctl status firewalld 若没有开启则开启systemctl start firewalld 查看所有开启的端口firew ...
- CentOS 7 与老版本CentOS防火墙配置的区别
一.CentOS 7 以下版本防火墙的配置: 1.开放80,22,8080 端口/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/ipt ...
- CentOS 6.9下的Setup工具(用于管理服务/防火墙/网络配置/验证服务)
说明:Setup工具套件好像是CentOS下特有的用于管理服务/防火墙/网络配置等,其实就是基于命令行模式界面的GUI工具.唯一特点就是方便. 安装: #安装Setup命令工具 yum -y inst ...
- Centos 7防火墙策略配置指南
Centos 7防火墙策略配置指南 -- 清听凌雪慕忆 @ 目录 1. 开启防火墙 1.1 user切换到root用户 1.2 查看防火墙服务状态 1.3 查看firewall的状态 1.4 启动/关 ...
- 解决宿主机不能访问虚拟机CentOS中的站点 | 更新CentOS防火墙设置开启80端口访问
前阵子在虚拟机上装好了centos6.0,并配好了nginx+php+mysql,但是本机就是无法访问.一直就没去折腾了. 具体情况如下 1.本机能ping通虚拟机 2.虚拟机也能ping通本机 3. ...
- centos防火墙操作
centos防火墙基本操作 #/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT#/sbin/iptables -I INPUT -p tcp -- ...
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
Centos下安装配置LAMP(Linux+Apache+MySQL+PHP) 关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...
随机推荐
- Django组件——forms组件
一.校验字段功能 通过注册用户这个实例来学习校验字段功能. 1.模型:models.py from django.db import models # Create your models here. ...
- Django——form组件和ModelForm
一.原生form实现书城增删改查 1.构建模型并完成数据库迁移 (1)构建书城模型 from django.db import models # Create your models here. # ...
- 详解nodejs中使用socket的私聊和公聊的办法
详解nodejs中使用socket的私聊和公聊的办法 nodejs的应用中,关于socket应该是比较出彩的了,socket.io在github上有几万人的star,它的成功应该是不输于express ...
- 用nodejs做一个svn密码修改页面
linux上配置好svn服务后,管理修改密码还得去手工修改passwd这个文件,略麻烦,其实网上应该有配套的web管理修改界面程序.但我想自己用nodejs写一个,因为用node不用配置复杂的服务器. ...
- GET来传递数据的实例
实例 下面实例是一点典型的使用GET来传递数据的实例: 客户端请求: GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 libcurl/7.16.3 Op ...
- solidity语言14
库(Libraries) 库类似合约,实现仅在专门地址部署一次,使用EVM的DELEGATECALL的功能重复使用的目的.意思是当库函数被调用后,代码执行在被调用的合约的环境.例如,使用this调用合 ...
- SqlServer50条常用查询语句
Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师表 问题 ...
- QQ空间那年今日 & 人人过往的今天
都说天下文章一大抄!就看你会抄不会抄! 过往的今天这个功能很新颖,不过最后还是被企鹅抄走了~该出手时就出手! 自从过往的今天功能低调上线后,断断续续总是有人提到这个功能,有褒有贬: 顶的认为人人让自己 ...
- ubuntu 可以加速播放的播放器SMPlayer 16.4安装
直接贴命令 sudo apt-add-repository ppa:rvm/smplayer sudo apt-get update sudo apt-get install smplayer smp ...
- Bootstrap table分页问题汇总
首先非常感谢作者针对bootstrap table分页问题进行详细的整理,并分享给了大家,希望通过这篇文章可以帮助大家解决Bootstrap table分页的各种问题,谢谢大家的阅读. 问题1 :服务 ...