linux管理防火墙
操作系统环境:CentOS Linux release 7.0.1406(Core) 64位
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
systemctlrestart iptables.service #最后重启防火墙使配置生效
systemctlenable iptables.service #设置防火墙开机启动
在没有找到 /etc/systemconfig/iptables 时解决办法:
执行一下命令:
- systemctl stop firewalld
- systemctl mask firewalld
并且安装iptables-services:
- yum install iptables-services
设置开机启动:
- systemctl enable iptables
- systemctl stop iptables
- systemctl start iptables
- systemctl restart iptables
- systemctl reload iptables
保存设置:
- service iptables save
最新文章
- VS2013预览版安装 体验截图
- SpringBoot配置属性之DataSource
- select制作分层级目录,让select显示和可下拉选择的";不一样";
- C#利用iComparable接口实现List排序
- ads
- java值得注意的几个问题
- java中对浮点数精度的处理DecimalFormat
- Android的Eclipse升级笔记
- Android Studio下添加引用jar文件和so文件
- a标签加绝对定位在图片上面,a的链接和块状属性block失效,而且是所有IE版本都失效的
- linux install nginx error
- OpenCV教程二 - Mat对象与它各种用法
- 网页的居中显示,使用了margin、clear:both
- 【IOS 开发】Objective - C 面向对象高级特性 - 包装类 | 类处理 | 类别 | 扩展 | 协议 | 委托 | 异常处理 | 反射
- Stream闪亮登场
- FastDFS数据存储
- ImportError: DLL load failed: 找不到指定的模块。
- 深度卷积网络(DCNN)和人类识别物体方法的不同
- 搭建Airflow数据流调度器
- h5直播
热门文章
- Python itchat.get_chatrooms() 抓取群聊不全的问题
- Java多线程之内存模型
- JavaWeb网上图书商城完整项目--27.注册页面之注册按钮图片切换实现
- 10、一个action中处理多个方法的调用第二种方法method的方式
- npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs'
- 上位机面试必备——TCP通信灵魂二十问【下】
- 入门大数据---Scala学习
- ajax前后端交互原理(6)
- ASP.NET MVC 中解决Session,Cookie等依赖的方式
- ASP.NET MVC 四种Controller向View传值方法