linux网络操作 防火墙相关操作
防火墙状态
查询防火墙状态
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网络操作 防火墙相关操作的更多相关文章
- Linux网络——配置防火墙的相关命令
Linux网络——配置防火墙的相关命令 摘要:本文主要学习了如何在Linux系统中配置防火墙. iptables命令 iptables准确来讲并不是防火墙,真正的防火墙是运行于系统内核中的netfil ...
- centos 7 防火墙相关操作
centos 7 防火墙相关操作 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewal ...
- Linux系统防火墙相关操作
服务器重启后防火墙会自动开启,需要把防火墙关闭 以下为对防火墙进行的相关操作 查看防火墙状态 systemctl status firewalld service iptables status 暂时 ...
- linux常用命令---用户相关操作
用户相关操作
- Linux网络配置及相关命令
Linux的网络配置是曾一直是我学习Linux的埋骨之地,投入了大量的精力和心神让自己的虚拟机联网.后来发现,仅仅是一个大意,我在这个坑上一躺就是一年半.现在总结一下这个伤心地.希望对有帮助. VMw ...
- Linux 防火墙相关操作
目录 1.查看防火墙状态 2.部署防火墙 3.常用操作 4.其他操作 1.查看防火墙状态 systemctl status firewalld 绿字部分 Active:active(running) ...
- 【转】SVN linux命令及 windows相关操作(一)
从以下博客转载和整理: http://www.cnblogs.com/richcem/archive/2011/01/08/1930823.html http://blog.wpjam.com/m/t ...
- 【转】SVN linux命令及 windows相关操作(三)
TortoiseSVN是windows下其中一个非常优秀的SVN客户端工具.通过使用它,我们可以可视化的管理我们的版本库.不过由于它只是一个客户端,所以它不能对版本库进行权限管理. TortoiseS ...
- 【转】SVN linux命令及 windows相关操作(二)
转自这里:http://www.uml.org.cn/pzgl/200904246.asp 1 安装及下载client 端 2 什么是SVN(Subversion)? 3 为甚么要用SVN? 4 怎么 ...
随机推荐
- java io 好文传送
转自:白大虾 地址:https://www.cnblogs.com/baixl/p/4170599.html 主要内容 java.io.File类的使用 IO原理及流的分类 文件流 FileInput ...
- tslint无法工作:Failed to load the TSLint library for the document
1--- 2--- 3---
- Eclipse中使用MySql遇到:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading o
在Eclipse中使用MySQL遇到了点小问题 如果对Eclipse中配置MySql还有疑问的可以参考一下这篇博客:https://blog.csdn.net/qq_38247544/article/ ...
- 使用git命令行解决冲突
文章转载自:https://blog.csdn.net/sureSand/article/details/78765727 使用git和提交的代码有所冲突,用IDE自带的git工具功能多了反而不知道怎 ...
- Selenium WebDriver Api 知识梳理
之前一直没有系统的梳理WebDriver Api的相关知识,今天借此机会整理一下. 1.页面元素定位 1.1.8种常用定位方法 # id定位 driver.find_element_by_id() # ...
- Asp.net core 学习笔记 ( Identity 之 Authentication )
和从前的 identity 区别不是很大. 从 2.1 开始 vs 模板的 identity 都被封装了起来, 你几乎看不到任何一行代码, 需要向下面这样打开它, 才能做修改. 说一下比较常用的配置 ...
- Linux-Ubuntu16.0.4相关命令
1.更新软件源 sudo apt-get update 2.shell命令 基本格式:命令 [-选项] [-命令参数] ls #查看当前文件夹下的文件 ls -l XXXX #查看XXXX文件夹下的 ...
- PHP数组合并和去重的函数有哪些
PHP数组合并和去重的函数有哪些 一.总结 一句话总结:合并:array_merge() array_merge_recursive() +号:去重:array_flip() array_unique ...
- OnSen UI结合AngularJs打造”美团"APP"订单”页面 --Hybrid App
1.页面效果图: 演示链接地址:http://www.nxl123.cn/bokeyuan/meiTuanDemo_order/ 2.核心代码 order.html: <ons-page id= ...
- javaweb课程信息管理系统
1.DBUtil包连接数据库 2.Bin包设计成员函数及方法 3.Dao包设计sql语句 4.servlet包增删改查方法 5.service连接servlet 6.设计jsp增删改查页面 7.连接各 ...