CentOS7开放端口及开启防火墙

发布于 2018-09-28

CentOS7开放端口及开启防火墙

从CentOS7(RHEL7)开始,官方的标准防火墙设置软件从iptables变更为firewalld,相信不少习惯使用iptables的人会感到十分不习惯,但实际上firewalld更为简单易用。

一、firewall 防火墙

1、对于centos7自带的防火墙的相关指令

查看firewall的状态
systemctl status firewalld.service
开启firewall
systemctl start firewalld.service
停止firewall
systemctl stop firewalld.service
重启firewall
systemctl restart firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
开机启动firewall
systemctl enable firewalld.service

2、开放端口

开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重新载入
firewall-cmd --reload
查看端口
firewall-cmd --zone=public --query-port=80/tcp
删除端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent

二、iptables 防火墙

1、iptables防火墙的相关状态

关闭防火墙
service iptables stop
启动防火墙
service iptables start
重启防火墙
service iptables restart
查看防火墙状态
service iptables status
永久关闭防火墙
chkconfig iptables off
永久关闭后启用
chkconfig iptables on

2、开放端口

开放端口
iptables -A INPUT -p tcp --dport 8088 -j ACCEPT
喜欢 6
奋楫笃行,臻于至善!

相关文章

Linux 进程管理工具 supervisor 的安装及使用教程

Supervisor 是用 Python 实现的一个进程管理工具,可以很方便用来管理进程,包括启动、关闭及重启等操作,经常被用来监听 web 服务,一旦服务挂掉,可以让服务自动重启。Superviso...
阅读全文

通过脚本命令实现数据库定时自动备份

备份网站数据有很多种方法,今天为大家分享一下最常用的脚本备份命令。 编写脚本backup.sh #!/bin/bash tool=/usr/bin/mysqldump dd=`date +%Y%m%d...
阅读全文

Linux 自定义登录提示信息

想不想你的Linux登录界面个性一些?可以通过修改/etc/motd文件或/etc/issue文件的方式实现。/etc/issue文件的使用方法与/etc/motd文件相差不大,它们主要区别在于:当一...
阅读全文

Linux 查看端口占用情况

我们在使用一个新的端口时,有时候会发现它已经已经被其他进程占用了,在linux中如何查询端口被占用的情况呢,可以使用 lsof 和 netstat 命令。 1、lsof -i:端口号 用于查看某一端口...
阅读全文

Linux 的 chattr 命令详解

有时候你发现用root权限都不能修改某个文件,大部分原因是曾经用chattr命令锁定该文件了。chattr命令的作用很大,其中一些功能是由Linux内核版本来支持的,不过现在生产绝大部分跑的linux...
阅读全文

在 Ubuntu / Debian 中用 UFW 配置防火墙

之前整理过一篇在 CenterOS 下如何开启防火墙与开放端口的文章,除了 CenterOS ,Ubuntu 也是我们经常使用的 Linux 操作系统,那么在 Ubuntu下该如何开启防火墙与开放端口...
阅读全文

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注