{"id":53,"date":"2012-06-10T11:44:36","date_gmt":"2012-06-10T11:44:36","guid":{"rendered":"http:\/\/rmohan.com\/?p=53"},"modified":"2012-06-13T12:03:40","modified_gmt":"2012-06-13T04:03:40","slug":"configure-advanced-policy-based-firewall-apf-brute-force-detection-bfd-ddos-deflate","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=53","title":{"rendered":"Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate"},"content":{"rendered":"<p><strong>Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate <\/strong><\/p>\n<p><strong>Advanced Policy Firewall  <\/strong><\/p>\n<p><strong>Description:<\/strong><br \/>\nAdvanced Policy Firewall (APF) is an iptables(netfilter) based firewall system designed around the essential needs of today\u2019s Linux servers. The configuration is designed to be very informative and easy to follow. The management on a day-to-day basis is conducted from the command line with the \u2018apf\u2019 command, which includes detailed usage information on all the features.<\/p>\n<p>The technical side of APF is such that it utilizes the latest stable features from the iptables (netfilter) project to provide a very robust and powerful firewall. The filtering performed by APF is three fold:<br \/>\n1) Static rule based policies (not to be confused with a \u201cstatic firewall\u201d)<br \/>\n2) Connection based stateful policies<br \/>\n3) Sanity based policies<\/p>\n<p>Features:<br \/>\n&#8211; detailed and well commented configuration file<br \/>\n&#8211; granular inbound and outbound network filtering<br \/>\n&#8211; user id based outbound network filtering<br \/>\n&#8211; application based network filtering<br \/>\n&#8211; trust based rule files with an optional advanced syntax<br \/>\n&#8211; global trust system where rules can be downloaded from a central management server<br \/>\n&#8211; reactive address blocking (RAB), next generation in-line intrusion prevention<br \/>\n&#8211; debug mode provided for testing new features and configuration setups<br \/>\n&#8211; fast load feature that allows for 1000+ rules to load in under 1 second<br \/>\n&#8211; inbound and outbound network interfaces can be independently configured<br \/>\n&#8211; global tcp\/udp port &#038; icmp filtering with multiple filters (drop, reject, prohibit)<br \/>\n&#8211; configurable policies for each ip on the system with convenience variables to import settings<br \/>\n&#8211; packet flow rate limiting that prevents abuse on the most widely abused protocol, icmp<br \/>\n&#8211; prerouting and postrouting rules for optimal network performance<br \/>\n&#8211; dshield.org block list support to ban networks exhibiting suspicious activity<br \/>\n&#8211; spamhaus Don\u2019t Route Or Peer List support to ban known \u201chijacked zombie\u201d IP blocks<br \/>\n&#8211; any number of additional interfaces may be configured as trusted or untrusted<br \/>\n&#8211; additional firewalled interfaces can have there own unique firewall policies applied<br \/>\n&#8211; intelligent route verification to prevent embarrassing configuration errors<br \/>\n&#8211; advanced packet sanity checks to make sure traffic coming and going meets the strictest of standards<br \/>\n&#8211; filter attacks such as fragmented UDP, port zero floods, stuffed routing, arp poisoning and more<br \/>\n&#8211; configurable type of service options to dictate the priority of different types of network traffic<br \/>\n&#8211; intelligent default settings to meet every day server setups<br \/>\n&#8211; dynamic configuration of your servers local DNS revolvers into the firewall<br \/>\n&#8211; optional filtering of common p2p applications<br \/>\n&#8211; optional filtering of private &#038; reserved IP address space<br \/>\n&#8211; optional implicit blocks of the ident service<br \/>\n&#8211; configurable connection tracking settings to scale the firewall to the size of your network<br \/>\n&#8211; configurable kernel hooks (ties) to harden the system further to syn-flood attacks &#038; routing abuses<br \/>\n&#8211; advanced network control such as explicit congestion notification and overflow control<br \/>\n&#8211; helper chains for FTP DATA and SSH connections to prevent client side issues<br \/>\n&#8211; optional rate limited event logging<br \/>\n&#8211; logging subsystem that allows for logging data to user space programs or standard syslog files<br \/>\n&#8211; comprehensive logging of every rule added<br \/>\n&#8211; detailed startup error checking<br \/>\n&#8211; if you are familiar with netfilter you can create your own rules in any of the policy files<br \/>\n&#8211; pluggable and ready advanced use of QoS algorithms provided by the Linux<br \/>\n&#8211; 3rd party add-on projects that compliment APF features<\/p>\n<p><strong>Install Procedure <\/strong><\/p>\n<p>mkdir \/software<br \/>\ncd software<br \/>\nwget -c http:\/\/rfxnetworks.com\/downloads\/apf-current.tar.gz<br \/>\ntar -zxvf apf-current.tar.gz<br \/>\ncd apf-9.7-2\/<br \/>\n.\/install.sh<br \/>\ncp \/etc\/apf\/conf.apf \/etc\/apf\/conf.apf.bk<br \/>\nvi \/etc\/apf\/conf.apf<\/p>\n<p>DEVEL_MODE=\u201d0\u201d<br \/>\nIG_TCP_CPORTS=\u201d21,22,25,53,80,110,143,443,3306\u201d<br \/>\nIG_UDP_CPORTS=\u201d53,67,68,111,5353,48443\u201d<br \/>\nUSE_AD=\u201d1\u201d<\/p>\n<p> \/etc\/init.d\/apf restart<br \/>\n<strong><br \/>\nBrute Force Detection (BFD)<\/strong><\/p>\n<p>Brute Force Detection (BFD)<\/p>\n<p> 1) Download and Install Brute Force Detection (BFD)<br \/>\n    wget -c http:\/\/rfxnetworks.com\/downloads\/bfd-current.tar.gz<br \/>\n    tar xvfz bfd-current.tar.gz<br \/>\n    cd bfd-*<br \/>\n    .\/install.sh<br \/>\n    Backup and Edit BFD Configuration<br \/>\n    cp \/usr\/local\/bfd\/conf.bfd \/usr\/local\/bfd\/conf.bfd.ori<br \/>\n    vi \/usr\/local\/bfd\/conf.bfd<\/p>\n<p>    EMAIL_ALERTS=&#8221;0&#8243;<br \/>\n    EMAIL_ADDRESS=&#8221;admin@email.com&#8221;<br \/>\n    Backup and Edit BFD Ignore Hosts<br \/>\n    cp \/usr\/local\/bfd\/ignore.hosts \/usr\/local\/bfd\/ignore.hosts.ori<br \/>\n    vi \/usr\/local\/bfd\/ignore.hosts<\/p>\n<p>    192.168.1.108<br \/>\n    Run BFD<br \/>\n    bfd -s<\/p>\n<p><strong>DDoS Deflate<\/strong><\/p>\n<p>    Download and Install DDoS Deflate<br \/>\n    wget -c http:\/\/www.inetbase.com\/scripts\/ddos\/install.sh<\/p>\n<p>    sh install.sh<br \/>\n    Backup and Edit DDOS Configuration<br \/>\n    cp \/usr\/local\/ddos\/ddos.conf \/usr\/local\/ddos\/ddos.conf.ori<br \/>\n    vi \/usr\/local\/ddos\/ddos.conf<\/p>\n<p>    EMAIL_TO=&#8221;test@email.com&#8221;<br \/>\n    Run DDOS<br \/>\n    \/usr\/local\/ddos\/ddos.sh -c<\/p>\n<p><strong>Open a port in apf firewall and add trusted IP<\/strong><\/p>\n<p>Apf is a policy based iptable firewall which is very useful for blocking DDoS attack on heavily traffic servers.<br \/>\nThe issue is when we developrs\/testers are using the same server which will deny all the traffic from their static Ip given.<br \/>\nThis is a major headache in most cases.<\/p>\n<p>1. Opening port in apf firewall<br \/>\nEdit the file<br \/>\n&#8220;\/etc\/apf\/conf.apf&#8221;<\/p>\n<p>and find the entry of      IG_TCP_CPORTS&#8221;<\/p>\n<p>and added the ports to be opened in it.<\/p>\n<p>A sample entry like this, I add the port \u20199091? in it<br \/>\n<strong># Common inbound (ingress) TCP ports<br \/>\nIG_TCP_CPORTS=&#8221;20,21,22,25,53,80,110,143,443,465,993,995,3306&#8243;<\/strong><\/p>\n<p>Then restart the firewall<br \/>\n[root@host.mydomain.com] ~ >> apf -r<\/p>\n<p>Trusting our ip\u2019s on Apf firewall<\/p>\n<p>Add our ip information on \u201d<br \/>\n\/etc\/apf\/allow_hosts.rules<\/p>\n<p>\u201c. A sample entry like this<br \/>\n# inbound to destination port 22 from 192.168.2.1<br \/>\n# tcp:in:d=22:s=192.168.2.1#<br \/>\n# outbound to destination port 23 to destination host 192.168.2.1<br \/>\n# out:d=23:d=192.168.2.1#<br \/>\n# inbound to destination port 3306 from 192.168.5.0\/24<br \/>\n# d=3306:s=192.168.5.0\/24<br \/>\n# my IP ranges<br \/>\n10.0.4.0\/24<br \/>\n10.0.5.0\/24<br \/>\n10.0.6.0\/24<br \/>\ntcp:in:d=22:s=192.168.2.1#<br \/>\nout:d=23:d=192.168.2.1#<br \/>\nd=3306:s=192.168.5.0\/24<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate <\/p>\n<p>Advanced Policy Firewall <\/p>\n<p>Description: Advanced Policy Firewall (APF) is an iptables(netfilter) based firewall system designed around the essential needs of today\u2019s Linux servers. The configuration is designed to be very informative and easy to follow. The management on a day-to-day basis is [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/53"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=53"}],"version-history":[{"count":6,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":243,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions\/243"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}