debian配置防火墙
1 2 |
iptables -L vim /etc/iptables.test.rules |
1 2 3 4 5 6 |
// 下面的内容放到/etc/iptables.test.rules文件中 -A INPUT -s 192.168.2.0/24 -p tcp -m tcp --dport 631 -j ACCEPT -A INPUT -s 10.104.229.0/24 -p tcp -m tcp --dport 631 -j ACCEPT -A INPUT -p tcp -m tcp --dport 631 -j DROP COMMIT |
1 2 |
iptables-restore < /etc/iptables.test.rules vim /etc/network/if-pre-up.d/iptables |
1 2 3 |
// 下面的内容放到/etc/network/if-pre-up.d/iptables文件中 #!/bin/bash /sbin/iptables-restore < /etc/iptables.up.rules |
1 |
chmod +x /etc/network/if-pre-up.d/iptables |
// 清除全部的防火墙限制
1 |
iptables -F |