关闭系统默认iptables规则
- sudo apt update && sudo apt full-upgrade -y
- sudo apt install ufw -y
- sudo ufw enable
- sudo nano /etc/sysctl.conf #开启net.ipv4.ip_forward=1
- sudo ufw default allow forward
- sudo ufw default allow incoming
- sudo ufw default allow outgoing
- sudo ufw status verbose #确认防火墙已全部开放
- sudo systemctl restart ufw
安装nftables
- sudo apt update && sudo apt install nftables -y
- sudo mkdir /etc/nftables
- sudo nano /etc/nftables/default.nft
设置nftables规则
#!/usr/sbin/nft -fflush rulesettable ip default {chain input {type filter hook input priority 0; policy drop;iif lo acceptct state established, related accept# pingicmp type echo-request limit rate 500/second accept# SSHtcp dport 22 accept# Nginxtcp dport { 80, 443 } accept}}
启用nftables
- sudo systemctl start nftables
- sudo systemctl enable nftables
- sudo systemctl restart nftables
完
没有评论:
发表评论