May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate

Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate

Advanced Policy Firewall

Description:
Advanced Policy Firewall (APF) is an iptables(netfilter) based firewall system designed around the essential needs of today’s 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 ‘apf’ command, which includes detailed usage information on all the features.

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:
1) Static rule based policies (not to be confused with a “static firewall”)
2) Connection based stateful policies
3) Sanity based policies

Features:
– detailed and well commented configuration file
– granular inbound and outbound network filtering
– user id based outbound network filtering
– application based network filtering
– trust based rule files with an optional advanced syntax
– global trust system where rules can be downloaded from a central management server
– reactive address blocking (RAB), next generation in-line intrusion prevention
– debug mode provided for testing new features and configuration setups
– fast load feature that allows for 1000+ rules to load in under 1 second
– inbound and outbound network interfaces can be independently configured
– global tcp/udp port & icmp filtering with multiple filters (drop, reject, prohibit)
– configurable policies for each ip on the system with convenience variables to import settings
– packet flow rate limiting that prevents abuse on the most widely abused protocol, icmp
– prerouting and postrouting rules for optimal network performance
– dshield.org block list support to ban networks exhibiting suspicious activity
– spamhaus Don’t Route Or Peer List support to ban known “hijacked zombie” IP blocks
– any number of additional interfaces may be configured as trusted or untrusted
– additional firewalled interfaces can have there own unique firewall policies applied
– intelligent route verification to prevent embarrassing configuration errors
– advanced packet sanity checks to make sure traffic coming and going meets the strictest of standards
– filter attacks such as fragmented UDP, port zero floods, stuffed routing, arp poisoning and more
– configurable type of service options to dictate the priority of different types of network traffic
– intelligent default settings to meet every day server setups
– dynamic configuration of your servers local DNS revolvers into the firewall
– optional filtering of common p2p applications
– optional filtering of private & reserved IP address space
– optional implicit blocks of the ident service
– configurable connection tracking settings to scale the firewall to the size of your network
– configurable kernel hooks (ties) to harden the system further to syn-flood attacks & routing abuses
– advanced network control such as explicit congestion notification and overflow control
– helper chains for FTP DATA and SSH connections to prevent client side issues
– optional rate limited event logging
– logging subsystem that allows for logging data to user space programs or standard syslog files
– comprehensive logging of every rule added
– detailed startup error checking
– if you are familiar with netfilter you can create your own rules in any of the policy files
– pluggable and ready advanced use of QoS algorithms provided by the Linux
– 3rd party add-on projects that compliment APF features

Install Procedure

mkdir /software
cd software
wget -c http://rfxnetworks.com/downloads/apf-current.tar.gz
tar -zxvf apf-current.tar.gz
cd apf-9.7-2/
./install.sh
cp /etc/apf/conf.apf /etc/apf/conf.apf.bk
vi /etc/apf/conf.apf

DEVEL_MODE=”0”
IG_TCP_CPORTS=”21,22,25,53,80,110,143,443,3306”
IG_UDP_CPORTS=”53,67,68,111,5353,48443”
USE_AD=”1”

/etc/init.d/apf restart

Brute Force Detection (BFD)

Brute Force Detection (BFD)

1) Download and Install Brute Force Detection (BFD)
wget -c http://rfxnetworks.com/downloads/bfd-current.tar.gz
tar xvfz bfd-current.tar.gz
cd bfd-*
./install.sh
Backup and Edit BFD Configuration
cp /usr/local/bfd/conf.bfd /usr/local/bfd/conf.bfd.ori
vi /usr/local/bfd/conf.bfd

EMAIL_ALERTS=”0″
EMAIL_ADDRESS=”admin@email.com”
Backup and Edit BFD Ignore Hosts
cp /usr/local/bfd/ignore.hosts /usr/local/bfd/ignore.hosts.ori
vi /usr/local/bfd/ignore.hosts

192.168.1.108
Run BFD
bfd -s

DDoS Deflate

Download and Install DDoS Deflate
wget -c http://www.inetbase.com/scripts/ddos/install.sh

sh install.sh
Backup and Edit DDOS Configuration
cp /usr/local/ddos/ddos.conf /usr/local/ddos/ddos.conf.ori
vi /usr/local/ddos/ddos.conf

EMAIL_TO=”test@email.com”
Run DDOS
/usr/local/ddos/ddos.sh -c

Open a port in apf firewall and add trusted IP

Apf is a policy based iptable firewall which is very useful for blocking DDoS attack on heavily traffic servers.
The issue is when we developrs/testers are using the same server which will deny all the traffic from their static Ip given.
This is a major headache in most cases.

1. Opening port in apf firewall
Edit the file
“/etc/apf/conf.apf”

and find the entry of IG_TCP_CPORTS”

and added the ports to be opened in it.

A sample entry like this, I add the port ’9091? in it
# Common inbound (ingress) TCP ports
IG_TCP_CPORTS=”20,21,22,25,53,80,110,143,443,465,993,995,3306″

Then restart the firewall
[root@host.mydomain.com] ~ >> apf -r

Trusting our ip’s on Apf firewall

Add our ip information on ”
/etc/apf/allow_hosts.rules

“. A sample entry like this
# inbound to destination port 22 from 192.168.2.1
# tcp:in:d=22:s=192.168.2.1#
# outbound to destination port 23 to destination host 192.168.2.1
# out:d=23:d=192.168.2.1#
# inbound to destination port 3306 from 192.168.5.0/24
# d=3306:s=192.168.5.0/24
# my IP ranges
10.0.4.0/24
10.0.5.0/24
10.0.6.0/24
tcp:in:d=22:s=192.168.2.1#
out:d=23:d=192.168.2.1#
d=3306:s=192.168.5.0/24

3 comments to Configure Advanced Policy-based Firewall (APF), Brute Force Detection (BFD), DDoS Deflate

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>