在Debian系统上配置Kafka时,防火墙设置需注意以下事项:
ufw
或iptables
工具,例如:sudo ufw allow 9092/tcp # 使用ufw
sudo iptables -A INPUT -p tcp --dport 9092 -j ACCEPT # 使用iptables
sudo ufw deny in on eth0 from any to any port 9092 # 拒绝非信任IP
sudo ufw allow in on eth0 from 192.168.1.0/24 to any port 9092 # 允许特定网段
iptables
时,需保存规则以确保重启后生效:sudo iptables-save > /etc/iptables/rules.v4
telnet
或nc
命令测试端口是否可达,确保防火墙规则生效。