查看防火墙状态。
systemctl status firewalld

临时关闭防火墙命令。重启电脑后,防火墙自动起来。
systemctl stop firewalld

永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl disable firewalld

打开防火墙命令。
systemctl enable firewalld

防火墙开放特定端口:
①文件/etc/sysconfig/iptables
②添加:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
★具体参照/etc/sysconfig/iptables中的配置,一般默认会有一个22端口开放★
★数字3306代表开放3306端口,也可以改成其他的端口.★
③重启防火墙
service iptables restart

保存对防火墙的设置
serivce iptables save
=====================================
查看iptables规则及编号
iptables -nL –line-number

查看iptables规则及编号
iptables -nL –line-number

关闭所有的INPUT FORWARD(转发) OUTPUT的所有端口
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

只打开22端口
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT

参数讲解:
–A 参数就看成是添加一条规则
–p 指定是什么协议,我们常用的tcp 协议,当然也有udp,例如53端口的DNS
–dport 就是目标端口,当数据从外部进入服务器为目标端口
–sport 数据从服务器出去,则为数据源端口使用
–j 就是指定是 ACCEPT -接收 或者 DROP 不接收

禁止某个IP访问
iptables -A INPUT -p tcp -s 192.168.1.2 -j DROP
–s 参数是来源(即192.168.1.2)
后面拒绝就是DROP
删除规则
iptables -D INPUT 2
删除INPUT链编号为2的规则

原文:https://blog.csdn.net/snowfoxmonitor/article/details/47687173

Redhat 关闭防火墙和selinux的更多相关文章

  1. CentOS7 关闭防火墙和selinux

    本文将简单介绍在CentOS7上如何临时和永久关闭防火墙和selinux. 关闭防火墙 # 查看防火墙状态 [root@localhost ~]# systemctl status firewalld ...

  2. Centos7关闭防火墙与selinux

    CentOS 7.0默认使用的是firewall作为防火墙 直接关闭防火墙 systemctl stop firewalld.service #停止firewall systemctl disable ...

  3. CentOS 关闭防火墙和selinux

    1)关闭防火墙(每个节点) [Bash shell] 1 2 service iptables stop chkconfig iptables off 2)关闭selinux(重启生效) [Bash ...

  4. Linux关闭防火墙、SELinux

    使用root权限: Linux关闭防火墙: 1. chkconfig –list|grep iptables 2. chkconfig iptables off 永久关闭防火墙 3. chkconfi ...

  5. 永久关闭防火墙和selinux

    临时关闭selinux: setenforce 0    //设置SELinux 成为permissive模式 彻底禁用selinux: 使用root用户,vim /etc/sysconfig/sel ...

  6. [RHEL7.1]关闭防火墙及SElinux

    一.关闭防火墙 1. 先查看防火墙状态 [root@bogon ~]# 1 systemctl status firewalld firewalld.service - firewalld - dyn ...

  7. centos 7.X关闭防火墙和selinux

    一.关闭防火墙 centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的. 所以你只要停止firewalld服 ...

  8. linux关闭防火墙及selinux

    RHEL6.5 查看linux防护墙状态: service iptables status 关闭linux防火墙: 1)永久关闭,重启后生效 开启: chkconfig iptables on 关闭: ...

  9. 关闭防火墙,selinux,交互式设置IP的脚本

    脚本内容: #!/bin/bash # ens=$(cat /proc/net/dev | awk '{if($2>0 && NR > 2) print substr($1 ...

随机推荐

  1. Python Module_sys/random

    目录 目录 前言 软件环境 Python标准库初识 Python常用的标准库模块 dir 函数使用方法 sys操作系统功能模块 sysstdinsysstdoutsysstderr标准IOError流 ...

  2. ES6的对象属性简写

    在ES6中允许我们在设置一个对象的属性的时候不指定属性名. 不使用ES6: const name='Ming', age='18', city='Shanghai'; const student ={ ...

  3. Active Directory Users and Computers 安装与使用(win7&win10)

    一.         ADUC安装 根据自己电脑所使用的Windows操作系统,找到对应的ADUC管理工具补丁包点击下载后安装. Windows7补丁下载链接:https://www.microsof ...

  4. 服务器被植入木马,CPU飙升200%

    线上服务器用的是某云的,欢快的完美运行着Tomcat,MySQL,MongoDB,ActiveMQ等程序.突然一则噩耗从前线传来:网站不能访问了! 此项目是我负责,我以150+的手速立即打开了服务器, ...

  5. 为webService添加Interceptor(拦截器)

    今天写一个简单的拦截器,以webService接口为例: 背景:H5的一个项目,只要调用H5webService 接口下面的方法都会触发一个AuthorityInterceptor去验证是否调用类型是 ...

  6. 26. Remove Duplicates from Sorted Array(代码思路新奇)

    Given a sorted array, remove the duplicates in-place such that each element appear only once and ret ...

  7. webpack入门学习手记(一)

    本人微信公众号:前端修炼之路,欢迎关注. 之前用过gulp.grunt,但是一直没有学习过webpack.这两天刚好有时间,学习了下webpack.webpack要想深入研究,配置的东西比较多,网上的 ...

  8. 将数据库模型放入到.Net Core的类库中

    一.前提概要 今年某天突然无聊,就决定学习.net core,此时的版本已经是.net core 1.1了.之前一直是用.net framework做项目,一直对Html.EditFor()等Html ...

  9. node.js 设置静态文件托管

    1.在app.js文件中设置静态文件托管 /*应用程序入口文件*/ /*加载express模块*/ var express = require('express'); /*加载模板处理模块*/ var ...

  10. SQL的编写顺序和执行顺序,以及空值处理,别名处理,转义字符处理

    SQL即结构化查询语言.也就是用来从数据库中操作数据的.数据总的来说就是增删改查CRUD. 一,sql的分类,大致有四类: 1)DDL : 数据定义语言 create alter drop trunc ...