iptables防火墙启动停止和基本操作


iptables是centos7之前常用的防火墙,在centos7上使用了firewall

防火墙基本操作:

# 查询防火墙状态
service iptables status
# 关闭防火墙
service iptables stop
# 开启防火墙
service iptables start
# 重启防火墙
service iptables restart
# 永久关闭防火墙
chkconfig iptables off
# 永久关闭后开启防火墙
chkconfig iptables on
# 查询当前iptables的规则
iptables -L --line-numbers

开放端口和关闭端口

关于端口的开放和关闭,我们这里采用编辑配置文件的形式,配置文件是/etc/sysconfig/iptables

在配置文件中添加一行

# 开放端口
-A INPUT -p tcp --dport 22 -j ACCEPT
# 关闭端口
-A INPUT -p tcp --dport 22 -j DROP

如果 /etc/sysconfig/iptables文件不存在

原因:在阿里云服务器和部分centos7中,iptables防火墙默认是被禁掉的,一般也没有配置过任何防火墙的策略,所有不存在/etc/sysconfig/iptables文件。

解决:使用iptables命令随便写一条防火墙规则,如:

iptables -P OUTPUT ACCEPT

然后使用service iptables save进行保存,默认就保存到了/etc/sysconfig目录下的iptables文件中

iptables防火墙常用命令的更多相关文章

  1. iptables防火墙常用命令参数

    iptable添加一条规则开放22端口 iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -A OUTPUT -p tcp --sport ...

  2. linux下防火墙开启某个端口号及防火墙常用命令使用

    linux防火墙常用命令 1.永久性生效,重启后不会复原 开启:chkconfigiptables on 关闭:chkconfigiptables off 2.即时生效,重启后复原 重启防火墙 方式一 ...

  3. Iptables 防火墙常用配置

    转至:https://blog.csdn.net/lswzw/article/details/87971259 Iptables 防火墙常用配置 概念 命令行模式 查看 & 命令 -n:直接显 ...

  4. iptables防火墙常用配置介绍

    参考地址 http://www.cnblogs.com/metoy/p/4320813.html http://netfilter.org/ iptables http://man.chinaunix ...

  5. Centos7防火墙常用命令

    有些人安装的linux的系统默认防火墙不是iptables,而是firewall,那就得使用以下方式关闭防火墙了. >>>关闭防火墙 systemctl stop firewalld ...

  6. Fortigate防火墙常用命令

    命令结构 #config 对策略,对象等进行配置 #get  查看相关对象的参数 #show 查看配置文件 #diagnose 诊断命令 #execute  常用的工具命令,如ping treacer ...

  7. iptables防火墙相关命令详解

    前提基础: 当主机收到一个数据包后,数据包先在内核空间中处理,若发现目的地址是自身,则传到用户空间中交给对应的应用程序处理,若发现目的不是自身,则会将包丢弃或进行转发. iptables实现防火墙功能 ...

  8. Ubuntu防火墙常用命令

    Ubuntu默认防火墙安装.启用.配置.端口.查看状态相关信息 最简单的一个操作: sudo ufw status(如果你是root,则去掉sudo,ufw status)可检查防火墙的状态,我的返回 ...

  9. Centos7防火墙常用命令及mask锁定不能添加端口问题

    一.开放端口 sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent sudo firewall-cmd --reload 二. ...

随机推荐

  1. MUI使用h5+进行召唤各大APP应用市场调用启动的包名和方式

    转载自:https://blog.csdn.net/u012442504/article/details/87367153 // 扩展API加载完毕后调用onPlusReady回调函数 documen ...

  2. java 中的编码

    1.1字节=8位,1024字节=1KB2.16进制0x12345678,其二进制为00010010 00110100 01010110 01111000共4字节3.字节序:两个或多个字节存放的先后顺序 ...

  3. 对includes的研究

    1.includes() 方法用来判断一个数组是否包含一个指定的值,如果是返回 true,否则false. 2.let site = ['runoob', 'google', 'taobao']; s ...

  4. LeetCode 1143 最长公共子序列

    链接:https://leetcode-cn.com/problems/longest-common-subsequence 给定两个字符串 text1 和 text2,返回这两个字符串的最长公共子序 ...

  5. M(model)V(view)C(controller,serlvet),(分) 静态工厂模式,单例模式

  6. js数字每3位加一个逗号

    if(typeof val ==="number"){ var str = val.toString(); ? /(\d)(?=(\d{})+\.)/g : /(\d)(?=(?: ...

  7. RedisTemplate访问Redis数据结构(前言)

    Redis五种基本数据结构 redis提供键值对的形式对数据进行存储.支持五种数据类型:String(字符串),List(链表),Hash(散列),Set(无序集合),ZSet(有序集合).下面是网上 ...

  8. Codeforces Round #587 (Div. 3) F. Wi-Fi(单调队列优化DP)

    题目:https://codeforces.com/contest/1216/problem/F 题意:一排有n个位置,我要让所有点都能联网,我有两种方式联网,第一种,我直接让当前点联网,花费为i,第 ...

  9. SQLserver基础--连接查询、联合查询、索引

    一.子查询补充: Exists的用法:select*from haha where exists(select*from bumen where bumen.code=haha.bumen,and b ...

  10. tp5关联模型进行条件查询

    public function wordOne(){ return $this->hasOne('TeachWord','id','w_id')->field('id,pid,title' ...