linux学习:防火墙iptables

本文涉及的产品
云防火墙,500元 1000GB
简介:

常用命令

查看:

1
service iptables status

关闭:

1
/etc/rc.d/init.d/iptables stop(或者service iptables stop)

永久关闭:

1
chkconfig iptables off

重启防火墙:

1
service iptables restart


开放某某端口

1、 用root用户修改/etc/sysconfig/iptables

1
vi /etc/sysconfig/iptables

 添加需开放的端口:如8080端口

1
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

 如:

  wKioL1k2p12x3_0WAAAMH7oFRQ0847.jpg

 注意:要放在COMMIT之前。

2、重启防火墙

1
service iptables restart

解决CentOS(6和7版本),/etc/sysconfig/下没有iptables的问题

一、Centos 6版本解决办法:

1.任意运行一条iptables防火墙规则配置命令:

1
iptables -P OUTPUT ACCEPT

2.对iptables服务进行保存:

1
service iptables save

3.重启iptables服务:

1
service iptables restart

二、Centos 7版本解决办法:

1、停止并屏蔽firewalld服务

1
2
systemctl stop firewalld
systemctl mask firewalld

2、安装iptables-services软件包

1
yum install iptables-services

3、在引导时启用iptables服务

1
systemctl enable iptables

4、启动iptables服务

1
systemctl start iptables

5、保存防火墙规则

1
2
3
service iptables save
/usr/libexec/iptables/iptables.init save


另外:管理iptables服务

1
systemctl [stop|start|restart] iptables

本文转自我爱大金子博客51CTO博客,原文链接http://blog.51cto.com/1754966750/1902227如需转载请自行联系原作者

我爱大金子
相关文章
|
1月前
|
Linux 网络性能优化 网络安全
Linux(openwrt)下iptables+tc工具实现网络流量限速控制(QoS)
通过以上步骤,您可以在Linux(OpenWrt)系统中使用iptables和tc工具实现网络流量限速控制(QoS)。这种方法灵活且功能强大,可以帮助管理员有效管理网络带宽,确保关键业务的网络性能。希望本文能够为您提供有价值的参考。
96 28
|
2月前
|
监控 安全 Linux
启用Linux防火墙日志记录和分析功能
为iptables启用日志记录对于监控进出流量至关重要
|
5月前
|
机器学习/深度学习 安全 网络协议
Linux防火墙iptables命令管理入门
本文介绍了关于Linux防火墙iptables命令管理入门的教程,涵盖了iptables的基本概念、语法格式、常用参数、基础查询操作以及链和规则管理等内容。
265 73
|
3月前
|
存储 运维 Linux
Linux防火墙firewall的使用
CentOS 7 中的 firewalld 是基于 Netfilter 的防火墙服务,支持动态配置,无需重启服务即可生效。它通过区域管理网络流量,每个区域可以设置不同的防火墙规则。默认区域为 public,可以通过命令行工具 firewall-cmd 进行管理和配置。firewalld 提供了丰富的预定义服务和区域,方便用户根据需求进行灵活配置。
66 0
|
4月前
|
运维 网络协议 安全
Linux安全运维--一篇文章全部搞懂iptables
Linux安全运维--一篇文章全部搞懂iptables
87 1
|
6月前
|
Linux 网络安全
linux关闭方防火墙的命令
linux关闭方防火墙的命令
118 2
|
6月前
|
安全 Linux 应用服务中间件
在Linux中,包过滤防火墙与代理应用防火墙有什么区别?有哪些相应的产品?
在Linux中,包过滤防火墙与代理应用防火墙有什么区别?有哪些相应的产品?
|
7月前
|
网络协议 Linux 网络安全
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
在CentOS 7中,新引入了firewalld服务(防火墙),取代了CentOS 6之前的iptables服务(防火墙)。
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
|
6月前
|
Linux 网络安全
在Linux中,如何设置防火墙规则?
在Linux中,如何设置防火墙规则?
|
6月前
|
Linux 网络安全
在Linux中,iptables和firewalld两种防火墙如何使用?
在Linux中,iptables和firewalld两种防火墙如何使用?