给FreeBSD加上了防火墙

  早上去给FreeBSD(4.10)加了个防火墙;
  1.   编译内核:进入 /sys/i386/conf ,cp GENERIC 到 Kernel_IPFW ,在Kernle_IPFW中添加

    options     IPFIREWALL
    options     IPFIREWALL_FORWARD
    options     IPFIREWALL_VERBOSE
    options     IPFIREWALL_VERBOSE_LIMIT=100
    options     IPFIREWALL_DEFAULT_TO_ACCEPT


  2. 然后 config Kernel_IPFW (在/sys/i386/conf 目录中的 LINT 有全部内核选项的说明);按照shell的提示编译并安装新的 Kernel_IPFW。

  3. 在 /etc/rc.conf 添加

    firewall_enable="YES"
    firewall_script="/etc/rc.firewall"
    firewall_type="/etc/ipfw.conf"
    firewall_quiet="YES"
    firewall_logging_enable="NO"


  4. 在 /etc/ipfw.conf 中加入

    add 00001 deny log ip from any to any ipopt rr
    add 00002 deny log ip from any to any ipopt ts
    add 00003 deny log ip from any to any ipopt ssrr
    add 00004 deny log ip from any to any ipopt lsrr
    add 00005 deny tcp from any to any in tcpflags syn,fin
    add 65500 allow tcp from any to me setup limit src-addr 8

    #可以比较有效的防止DDOS


  5. 如果要使用SSH需要编辑 /etc/rc.firewall ,这个文件应该仔细阅读,防火墙规则太多可以在这里编辑。

  6. 可以防止一般的 DDOS,扫描,ICMP攻击等等攻击,若要求更高,可以参考运用sysctl,ipfliter等,修改 /etc/rc.firewall 可以实现更多过滤功能,同样也可以把他变成一台比较专业的防火墙(主要参考编辑 /etc/rc.firewall )。
原文地址:https://www.cnblogs.com/fred/p/87555.html