请输入手机号码
请输入密码
在美国服务器上设置防火墙的实用步骤
一 规划与准备
二 Linux 服务器配置
1) 启动与开机自启:systemctl start firewalld && systemctl enable firewalld
2) 放行必要服务:firewall-cmd --permanent --add-service=ssh、--add-service=http、--add-service=https
3) 重新加载:firewall-cmd --reload
4) 按需限制管理源 IP(示例):firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="22" protocol="tcp" accept'
1) 安装与启用:apt update && apt install ufw -y && ufw enable
2) 默认策略:ufw default deny incoming、ufw default allow outgoing
3) 放行端口:ufw allow 22/tcp, 80/tcp, 443/tcp
4) 状态检查:ufw status verbose
1) 允许回环与已建立连接:iptables -A INPUT -i lo -j ACCEPT、iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
2) 放行服务端口:iptables -A INPUT -p tcp --dport 22 -j ACCEPT、-p tcp --dport 80 -j ACCEPT、-p tcp --dport 443 -j ACCEPT
3) 默认拒绝入站:iptables -P INPUT DROP(务必确保已有 SSH 规则后再设置)
4) 保存规则(视发行版):iptables-save > /etc/iptables/rules.v4 或 service iptables save
三 Windows 服务器配置
New-NetFirewallRule -DisplayName "Allow HTTP" -Direction Inbound -LocalPort 80 -Protocol TCP -Action AllowNew-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow四 云服务器与多层防护
五 验证与运维清单
ssh -p 22 user@server_ipcurl -I https://your_domainnc -vz server_ip 80、443、22sudo grep 'IN' /var/log/syslog | less 查看防火墙日志;