CentOS 7 下的 Firewall
CentOS 7 默认实用的用Firewalld作为防火墙,摒弃了原先的iptables。但是内核还是使用iptable作为管理
参考文档
https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html
http://www.myhome.net.tw/2015_02/p10.htm
firewall的启动和关闭命令
#systemctl start firewalld #systemctl enable firewalld #systemctl stop firewalld #systemctl disable firewalld #systemctl status firewalld
1Firewalld目录
/usr/lib/firewalld 这个目录是预设的设定资料,就是最原始的配置。可以在其目录下面看到很多的xml文件。
/etc/firewalld 存放现在正在实用的配置文档,如果下面没有就会采用/usr/lib/firewalld 目录中默认的配置文档。
2Friewall的命令
可以通过GUI界面来管理firewalld ,在有视窗的centos中,Applications->sundry->firewall可以来管理和配置
也可以通过命令行的方式来管理 firewall-cmd来具体的配置,可以实用man命令来了解firewalld相关命令的实用方式
# man firewalld.conf # man firewall-cmd # man firewalld.zone # man firewalld.service # man firewalld.icmptype # man firewalld.direct
常用的命令如下
1 添加http和https服务
# firewall-cmd --permanent --zone=public --add-service=http # firewall-cmd --permanent --zone=public --add-service=https # firewall-cmd --reload(不中断连接加载)
其中 --permanent(翻译:永久)是永久修改
2 修改SSH的端口22到23456
[root@localhost ~]# cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/ [root@localhost ~]# vi /etc/firewalld/services/ssh.xml <?xml version="1.0" encoding="utf-8"?> <service><short>SSH</short><description>Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.</description><port protocol="tcp" port="23456"/> </service> [root@localhost ~]# firewall-cmd --complete-reload (中断连接加载) [root@localhost ~]# vi /etc/ssh/sshd_config # $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $# This is the sshd server system-wide configuration file. See # sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/local/bin:/usr/bin# The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value.# If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # Port 23456 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: [root@localhost ~]# systemctl restart sshd [root@localhost ~]# systemctl status sshd sshd.service - OpenSSH server daemonLoaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)Active: active (running) since Mon 2015-08-31 17:47:22 CST; 25s agoMain PID: 12302 (sshd)CGroup: /system.slice/sshd.service?..12302 /usr/sbin/sshd -DAug 31 17:47:22 localhost.localdomain systemd[1]: Started OpenSSH server daemon. Aug 31 17:47:22 localhost.localdomain sshd[12302]: Server listening on 0.0.0.0 port 23456. Aug 31 17:47:22 localhost.localdomain sshd[12302]: Server listening on :: port 23456. Aug 31 17:47:23 localhost.localdomain python[12304]: SELinux is preventing /usr/sbin/sshd from name_bind access on the tcp_socket port 23456.***** Plugin bind_ports (92.2 confidence) suggests ************************... Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
转载于:https://blog.51cto.com/lixiaotao/1690193
CentOS 7 下的 Firewall相关推荐
- CentOS 7下安装Nextcloud搭建个人网盘
[转载自 https://www.linuxidc.com/Linux/2018-11/155310.htm] 该方法是在linxu公社中发布的.感谢作者! 本人亲测,此方法可行,我在手机.电脑上都可 ...
- Linux(CentOS)下,各种协议,端口号
Linux(CentOS)下,各种配置文件如下: DNS:cat /etc/resolv.conf 主机名:cat etc/sysconfig/network 私有主机名:cat /etc/hosts ...
- 玩PT需要SeedBox,关于在CentOS系统下架设SeedBox软件Transmission
原文转载自http://www.ziliaoboke.com/pt-seedbox-transmission.html 最近喜欢上了玩PT,喜欢上了高清电影,在大概从4月29号开始起,大概20天的时间 ...
- 【傻瓜教程】CentOS 7 下 LNMP 环境搭建过程
1.安装MariaDB CentOS 7 下,推荐使用MariaDB(MySQL的一种开源分支),且建议用yum安装. 安装命令 yum -y install mariadb mariadb-serv ...
- CentOS(linux) 下JDK的安装
CentOS(linux) JDK的安装 第一篇博客有不足之处,请大家多指教.^_^ linux下装JDK的文章网上有一大堆我就不照搬了. 本文讲新手如何取巧的在linux下安装JDK. CentOS ...
- 使用 yum 安装Docker(CentOS 7下)
使用 yum 安装(CentOS 7下) Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker . 通过 uname ...
- CentOS 6下编译安装Nginx
CentOS 6下编译安装Nginx By:老宁 一.准备make环境 yum -y install gcc gcc-c++ automake autoconf libtool make 二.准备 ...
- CentOS 7下Python环境设置 - 1
安装Python 3 CentOS 7下自带了Python 2.7,所以如果要使用Python 3,则需要重新安装Python 3 1.下载Python3.5的包 wget https://www.p ...
- Centos环境下部署游戏服务器-软件安装
这篇文章主要介绍一下游戏服务器需要安装的软件和需要修改的配置.现介绍下项目,本项目服务器端是c++ + mysql组合,客户端是as写的,需要安装的服务为Mysql,Php,Apache, 以及一个n ...
最新文章
- keras和tensorflow 报错解决:UserWarning: Method on_batch_end() is slow compared to the batch update Check
- web开发·基本网页实现(基于CSS盒子模型+PS辅助使用)
- linux中mysql如何删除库,Linux环境下MySQL基础命令(2)----查看、创建、删除库和表...
- POJ1033 Defragment
- 解决DELL服务器每次开机提示F1F2,需要F1才可以进系统的方法
- 如何写前端开发的改进建议书?
- linux 极路由救砖,极路由三不死u-boot刷机方法
- [算法]代码运行时间增长数量级对比 线性级别N vs 线性对数级别 NlgN
- 银行加息有什么影响(央行加息,对股市和房价有何影响?)
- 如何给HTML文件加一张背景图,如何在css中添加背景图?
- python如何给某列数据打标签_Python map, apply, transform 打标签方法汇总(初阶到高阶)...
- 背景建模方法论文总结
- Python攻城师的成长————css语法、伪元素选择器(部分)
- 解决:id you register the component correctly? For recursive components, make sure to provide the “name
- 《MATLAB SYNTAX》第4章 多项式
- 用于音频信号去噪的谱相减和陷波滤波的比较(Matlab代码实现)
- IDEA配置关联Git
- 手把手教你做音乐播放器(五)音乐列表的存储(上)
- 我的老师,“身怀绝技”!
- springboot问题排解