Ubuntu下的防火墙

Ubuntu下的防火墙Gufw-ufw
Gufw是ufw的桌面版本,网上有Gufw的安装和配置方法,但是我认为并不是很好。网上的教程也有点愚弄大众的嫌疑,因为按照他的说法,最后防火墙根本就无法自动启动,每次要手动启动,还要每次输入密码,很麻烦,不推荐使用,还是终端下运行的这个ufw好。
相关阅读:Ubuntu 8.10下安装设置Gufw-ufw图形界面防火墙[多图]
测试环境:Ubuntu 10.04
1.安装 
sudo apt-get install ufw
 
2.启用 
sudo ufw enable 
sudo ufw default deny 
运行以上两条命令后,开启了防火墙,并在系统启动时自动开启。 
关闭所有外部对本机的访问,但本机访问外部正常。
 
3.开启/禁用 
sudo ufw allow|deny [service] 
打开或关闭某个端口,例如: 
sudo ufw allow smtp 允许所有的外部IP访问本机的25/tcp (smtp)端口 
sudo ufw allow 22/tcp 允许所有的外部IP访问本机的22/tcp (ssh)端口 
sudo ufw allow 53 允许外部访问53端口(tcp/udp) 
sudo ufw allow from 192.168.1.100 允许此IP访问所有的本机端口 
sudo ufw allow proto udp 192.168.0.1 port 53 to 192.168.0.2 port 53 
sudo ufw deny smtp 禁止外部访问smtp服务 
sudo ufw delete allow smtp 删除上面建立的某条规则
 
4.查看防火墙状态 
sudo ufw status
 
一般用户,只需如下设置: 
sudo apt-get install ufw 
sudo ufw enable 
sudo default deny 
以上三条命令已经足够安全了,如果你需要开放某些服务,再使用sudo ufw allow开启。
 
************************************************
Ubuntu 安装CSF防火墙
1. 安装
Login as the root user to SSH and run the following commands.
rm -fv csf.tgz
wget http://www.configserver.com/free/csf.tgz
apt-get install libwww-perl
tar -xzf csf.tgz
cd csf
sh install.sh
2. 防范DDOS攻击
Step 1 :  Open the CSF configuration file /etc/csf/csf.conf
Step 2 : In that search for option called CT_LIMIT, by default it will be like CT_LIMIT=0 , change this to CT_LIMIT=90 ,here 90 is the max no.of connections from an IP to your server ( choose this value according to your server usage )
Step 3:Now search for option called CT_PORTS.This option is used to specify the port for which you want prevent DOS attack.Since our aim is to prevent the DOS attck to apache – port 80 , change CT_PORTS = “” to CT_PORTS = “80″
3. 限制每个IP连接数
CONNLIMIT = "80;7"
4. PT_LIMIT = "0" 禁止程序内存不足时,发邮件
原文地址:https://www.cnblogs.com/huapox/p/3516368.html