Linux防火墙操作firewall、iptable

简介: 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
目录
相关文章
|
19天前
|
Linux Android开发
测试程序之提供ioctl函数应用操作GPIO适用于Linux/Android
测试程序之提供ioctl函数应用操作GPIO适用于Linux/Android
13 0
|
17小时前
|
存储 Linux C++
linux信号量与PV操作知识点总结
linux信号量与PV操作知识点总结
|
2天前
|
存储 Linux
Redhat Enterprise Linux磁带机简单操作
Redhat Enterprise Linux磁带机简单操作
|
4天前
|
运维 监控 Linux
如何在Linux上部署1Panel运维管理面板并远程访问内网进行操作
如何在Linux上部署1Panel运维管理面板并远程访问内网进行操作
10 0
如何在Linux上部署1Panel运维管理面板并远程访问内网进行操作
|
10天前
|
Shell Linux 开发工具
【Linux】环境变量常见指令操作&基本实验(入门必看!)
【Linux】环境变量常见指令操作&基本实验(入门必看!)
|
12天前
|
存储 关系型数据库 MySQL
linux安装MySQL8.0,密码修改权限配置等常规操作详解
linux安装MySQL8.0,密码修改权限配置等常规操作详解
|
15天前
|
XML 安全 Linux
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
|
16天前
|
XML 网络协议 安全
firewall防火墙详解
firewall防火墙详解
9 1
|
17天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
31 1
|
18天前
|
监控 Linux
linux下监控用户的操作记录
linux下监控用户的操作记录