Linux防火墙操作firewall、iptable

本文涉及的产品
云防火墙,500元 1000GB
简介: Linux防火墙操作firewall、iptable
iptables防火墙命令操作

Copy

# 查看防火墙状态
service iptables status
# 停止防火墙
service iptables stop
# 启动防火墙
service iptables start
# 重启防火墙
service iptables restart
# 永久关闭防火墙
chkconfig iptables off
# 永久关闭后重启
chkconfig iptables on
# 开放某个区间端口 iptables命令最后的ACCEPT表示公网可访问,换成whitelist则仅限服务器之间通过内网访问。# iptables -I:默认插入到第一行,原有规则后移。# iptables -A :默认追加到最后一行。
iptables -A INPUT -p tcp --dport 3000:3006 -j ACCEPT
# 开放单个端口 iptables命令最后的ACCEPT表示公网可访问,换成whitelist则仅限服务器之间通过内网访问。
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables文件操作

vim /etc/sysconfig/iptables

Copy

# 先关闭所有的3306端口
iptables -I INPUT -p tcp --dport 3306 -j DROP
# 开启ip段192.168.1.0/24端的3306访问
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 3306 -j ACCEPT
:wq!#保存# 重启使配置生效
service iptables restart
firewall防火墙

Copy

# 查看firewall服务状态
systemctl status firewalld
# 查看firewall的状态
firewall-cmd --state
# 开启、重启、关闭、firewalld.service服务
service firewalld start
service firewalld restart
service firewalld stop
# 查看防火墙规则
firewall-cmd --list-all
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
目录
相关文章
|
2月前
|
安全 Linux 应用服务中间件
在Linux中,包过滤防火墙与代理应用防火墙有什么区别?有哪些相应的产品?
在Linux中,包过滤防火墙与代理应用防火墙有什么区别?有哪些相应的产品?
|
2月前
|
Linux 网络安全
在Linux中,要想把iptable的规则保存到一个文件中如何做?如何恢复?
在Linux中,要想把iptable的规则保存到一个文件中如何做?如何恢复?
|
1月前
|
机器学习/深度学习 安全 网络协议
Linux防火墙iptables命令管理入门
本文介绍了关于Linux防火墙iptables命令管理入门的教程,涵盖了iptables的基本概念、语法格式、常用参数、基础查询操作以及链和规则管理等内容。
201 73
|
2月前
|
Linux 网络安全
linux关闭方防火墙的命令
linux关闭方防火墙的命令
63 2
|
2月前
|
Linux 网络安全
在Linux中,如何设置防火墙规则?
在Linux中,如何设置防火墙规则?
|
2月前
|
SQL 网络协议 安全
【Azure API 管理】APIM集成内网虚拟网络后,启用自定义路由管理外出流量经过防火墙(Firewall),遇见APIs加载不出来问题
【Azure API 管理】APIM集成内网虚拟网络后,启用自定义路由管理外出流量经过防火墙(Firewall),遇见APIs加载不出来问题
|
2月前
|
安全 Linux 测试技术
在Linux中,如何配置防火墙和安全规则?
在Linux中,如何配置防火墙和安全规则?
|
网络协议 安全 Linux
百度搜索:蓝易云【Linux系统下如何在防火墙开放指定端口】
在Linux系统中,防火墙是用于保护计算机安全的重要组成部分。默认情况下,大多数Linux发行版都会自带一个防火墙,如iptables、firewalld等。当我们需要运行特定的应用程序或服务时,需要在防火墙中开放相应的端口。下面就是Linux系统下如何在防火墙开放指定端口的详细步骤。
108 0
|
5月前
|
存储 安全 网络协议
使用 firewall-cmd 管理 Linux 防火墙端口
本文将介绍如何使用 firewall-cmd 工具在 Linux 系统中进行简单端口管理,包括开放、查询、关闭等操作。通过实例展示相关命令的用法,希望能对大家有所帮助。
660 0
|
5月前
|
网络协议 安全 Linux
linux配置防火墙 Centos7下 添加 端口白名单
linux配置防火墙 Centos7下 添加 端口白名单
945 0