防火墙状态

查询防火墙状态
service iptables status
停止防火墙
service iptables stop
启动防火墙
service iptables start
重启防火墙
service iptables restart
永久关闭防火墙
chkconfig iptables off
永久关闭后启动
chkconfig iptables on
关闭防火墙注意
*) 如果要关闭iptables ,可以通过命令 /etc/init.d/iptables stop 停止
*) 也可以通过 service iptables stop 来停止 注意:
以上命令虽然关闭了iptables,但是如果设置了自动启动的话,iptables会自动开启(命令chkconfig查看系统自动启动进程)
[root@ssgao1987 bin]# chkconfig |grep iptables
iptables       0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
'所以我们还要关闭自动启动,避免重启后又启动了防火墙'
[root@ssgao1987 bin]# chkconfig iptables off(设置自动启动为关闭 chkconfig --del iptables 移除开机自动启动)
[root@ssgao1987 bin]# chkconfig |grep iptables
iptables       0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
然后停止防火墙(service iptables stop)
[root@ssgao1987 bin]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter                   [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
[root@ssgao1987 bin]# service iptables status
iptables:未运行防火墙

防火墙打开某个端口

查看防火墙状态
[root@ssgao1987 bin]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 ``` ```                                                               (表示目前防火墙开着,只接受外面的(本机外)22端口)
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination        
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination      

编辑/etc/sysconfig/iptables防火墙配置文件

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT(打开2181端口)
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

重启防火墙: service iptables restatus

查看防火墙状态:
[root@ssgao1987 bin]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:2181
6    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination        
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

linux网络操作 防火墙相关操作的更多相关文章

  1. Linux网络——配置防火墙的相关命令

    Linux网络——配置防火墙的相关命令 摘要:本文主要学习了如何在Linux系统中配置防火墙. iptables命令 iptables准确来讲并不是防火墙,真正的防火墙是运行于系统内核中的netfil ...

  2. centos 7 防火墙相关操作

    centos 7 防火墙相关操作 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewal ...

  3. Linux系统防火墙相关操作

    服务器重启后防火墙会自动开启,需要把防火墙关闭 以下为对防火墙进行的相关操作 查看防火墙状态 systemctl status firewalld service iptables status 暂时 ...

  4. linux常用命令---用户相关操作

    用户相关操作

  5. Linux网络配置及相关命令

    Linux的网络配置是曾一直是我学习Linux的埋骨之地,投入了大量的精力和心神让自己的虚拟机联网.后来发现,仅仅是一个大意,我在这个坑上一躺就是一年半.现在总结一下这个伤心地.希望对有帮助. VMw ...

  6. Linux 防火墙相关操作

    目录 1.查看防火墙状态 2.部署防火墙 3.常用操作 4.其他操作 1.查看防火墙状态 systemctl status firewalld 绿字部分 Active:active(running) ...

  7. 【转】SVN linux命令及 windows相关操作(一)

    从以下博客转载和整理: http://www.cnblogs.com/richcem/archive/2011/01/08/1930823.html http://blog.wpjam.com/m/t ...

  8. 【转】SVN linux命令及 windows相关操作(三)

    TortoiseSVN是windows下其中一个非常优秀的SVN客户端工具.通过使用它,我们可以可视化的管理我们的版本库.不过由于它只是一个客户端,所以它不能对版本库进行权限管理. TortoiseS ...

  9. 【转】SVN linux命令及 windows相关操作(二)

    转自这里:http://www.uml.org.cn/pzgl/200904246.asp 1 安装及下载client 端 2 什么是SVN(Subversion)? 3 为甚么要用SVN? 4 怎么 ...

随机推荐

  1. Total Commander

    Total Commander 是一款应用于 Windows 平台的文件管理器 ,它包含两个并排的窗口,这种设计可以让用户方便地对不同位置的“文件或文件夹”进行操作,例如复制.移动.删除.比较等,相对 ...

  2. adb shell命令后出现error: device not found错误提示

    在cmd中输入adb shell进入linux shell环境前,需要把android模拟器打开(本文都是针对模拟器而言,并非真机).如果启动好了模拟器,且输入adb shell命令后出现error: ...

  3. QT json字符串生成和解析

    1         QT json字符串生成和解析 1.1  QT Json解析流程 (1)  字符串转化为QJsonDocument QJsonParseError json_error; QJso ...

  4. 00-python语言介绍

    以下为摘录的python的介绍 Python是一种解释型语言.这就是说,与C语言和C的衍生语言不同,Python代码在运行之前不需要编译.其他解释型语言还包括PHP和Ruby. Python是动态类型 ...

  5. Genome-wide gene-environment analyses of depression and reported lifetime traumatic experiences in UK Biobank

    Genome-wide gene-environment analyses of depression and reported lifetime traumatic experiences in U ...

  6. Bash Shell 注释多行的几种方法(转)

    很实用的小技巧. 我们shell脚本写好了,但是想一行一行测试,怎么办. 笨方法:每行前面加一个 #,有时候我们原脚本里面本来就有注释,所以想再恢复的时候就麻烦了. Bash Shell 注释多行的几 ...

  7. linux文件管理之管道与重定向

    ============================================================== 内容提要: 输入输出重定向.管道: 重定向的作用: 文件描述符 0 1 2 ...

  8. Spring Batch 基本的批处理指导原则

    下面是一些关键的指导原则,可以在构批量处理解决方案可以参考: 请记住,通常皮脸处理体系结构将会影响在线应用的体系结构,同时反过来也是一样的.在你为批量任务和在线应用进行设计架构和环境的时候请尽可能的使 ...

  9. Confluence 6 修改空间名字和标识

    希望修改空间名称: 在空间名称的边上,选择  图标. 输入新的空间名称,然后单击 保存(Save). 标识(Logo )- 修改空间的名称和标识. 重新组织(Reorder) - 拖动来从新组织快捷链 ...

  10. vue.js中 v-show在刷新页面时,会闪一下,如何解决?

    因为浏览器是html从上到下执行,先执行Dom元素,然后执行javaScript元素,v-show实在javaScript中控制,当走到javaScript时,Dom元素已经开始走动,所以如果网慢的话 ...