在Debian系统中,防火墙的权限设置通常涉及到iptables
或nftables
的使用。以下是关于如何在Debian上设置防火墙权限的基本步骤:
sudo apt update
sudo apt install iptables
sudo iptables -L -n -v
sudo iptables -A INPUT -p tcp --dport 22 -s 192.168.1.100 -j ACCEPT
sudo iptables-save > /etc/iptables/rules.v4
sudo nano /etc/systemd/system/iptables-restore.service
添加以下内容:
[Unit]
Description=Restore IPTables rules
Before=network.target
[Service]
Type=oneshot
ExecStart=/sbin/iptables-restore < /etc/iptables/rules.v4
[Install]
WantedBy=multi-user.target
启用并启动服务:
sudo systemctl enable iptables-restore.service
sudo systemctl start iptables-restore.service
sudo apt update
sudo apt install nftables
sudo nft list ruleset
sudo nft add rule ip filter input tcp dport 22 ip saddr 192.168.1.100 accept
sudo nft list ruleset > /etc/nftables.conf
sudo nano /etc/systemd/system/nftables-restore.service
添加以下内容:
[Unit]
Description=Restore nftables rules
Before=network.target
[Service]
Type=oneshot
ExecStart=/sbin/nft -f /etc/nftables.conf
[Install]
WantedBy=multi-user.target
启用并启动服务:
sudo systemctl enable nftables-restore.service
sudo systemctl start nftables-restore.service
通过以上步骤,你可以在Debian系统上设置和管理防火墙权限。