linux

SecureCRT如何配置Linux防火墙规则

小樊
43
2025-05-09 10:28:22
栏目: 智能运维

在SecureCRT中配置Linux防火墙规则通常涉及到通过SSH会话执行命令来管理iptables或firewalld防火墙。以下是一些基本的步骤和命令,用于在Linux系统中配置防火墙规则。

使用iptables配置防火墙规则

  1. 查看当前防火墙规则
iptables -L
  1. 设置默认策略
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
  1. 添加规则
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  1. 保存规则
service iptables save

或者

iptables-save > /etc/iptables/rules.v4
  1. 重启防火墙服务以应用规则
service iptables restart

或者

systemctl restart iptables

使用firewalld配置防火墙规则

  1. 查看当前防火墙规则
firewall-cmd --list-all
  1. 添加规则
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
  1. 保存规则
firewall-cmd --runtime-to-permanent
firewall-cmd --reload
  1. 关闭防火墙服务
systemctl stop firewalld
systemctl disable firewalld

0
看了该问题的人还看了