防火墙状态

查询防火墙状态
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. hive表的存储路径查找以及表的大小

    1.在hive中知道一个表的存储路径可以通过hive命令   desc formatted table_name 显示表的详细信息; 2.然后找到该表的存储路径 "Location:    ...

  2. ps p图

    1. 常用快捷键 ctrl + 单击 选中图层ctrl + j 复制出拷贝的图层 Shift+Alt+S 保存ctrl + s 保存shift + ctrl + alt + s 保存为 web 格式图 ...

  3. QT文件(夹)操作---QFile、QDir、QFileInfo、QTextStream和QDataStream异同

    1.1    文件和目录 QFile.QBuffer和QTcpSocket可支持读写设备,用open函数打开,用write或putChar函数写入.用read和readLine或readAll进行读取 ...

  4. 通过AndroidSDK自带的Tool在dos命令行窗口显示日志,并存入txt文档中

    1.在默认情况下,命令行窗口中使用的代码页是中文或者美国的,即编码是中文字符集或者西文字符集.  如果一个文本文件是utf-8的,那么在dos窗口中不能正确显示文件中的内容. 以下命令切换编码: ch ...

  5. phpstudy2018配置站点后500错误问题

    phpstudy2016没发现这个问题,这是因为新项目要使用laravel,php版本要求7.1,所有换成了2108,但是laravel的项目没问题,原来tp框架的都不能正常访问,最好查看nginx错 ...

  6. echarts画多条一元回归线

    理论上两点一线,只要两个点即可 option = { title: { text: '', left: 'center' }, tooltip: { // trigger: 'item', // fo ...

  7. Linux上rsync配置

    一.服务器端配置1.rsyncd.conf文件说明uid = rsync     #用户,用来控制用户访问模块目录的读写权限gid = rsync     #组,用来控制组访问模块目录的读写权限use ...

  8. pandas dataframe的合并(append, merge, concat)

    创建2个DataFrame: >>> df1 = pd.DataFrame(np.ones((4, 4))*1, columns=list('DCBA'), index=list(' ...

  9. usaco Transformations

    模拟就行.注意int arr[][]二维数组在定义时是二维数组,而函数传参时是指针.这意味着memset()的不同.传参时只能当作一维逐个memset. #include <iostream&g ...

  10. android -------- Data Binding的使用 ( 五) include

    Data Binding的中 include 标签的使用 inclune使用和原来一样,但要如何使数据也在 include中使用呢? 先看看我的布局文件 include的布局文件,也要使用 <l ...