UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Technical Support > Linux Dedicated Servers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 25-11-2006, 21:31
eUK-Scott's Avatar
System Administrator
 
Join Date: Oct 2006
Posts: 211
Wink Installing and Configuring APF for cPanel Server

Installing APF Firewall for cPanel

In this section, I would like to enumerate the steps to install APF firewall for CPanel. This would help any person who decides to install APF firewall by themselves, and is maybe dreading that decision, to do so in just 13 EASY-TO-DO steps.

First of all, like all tasks, there's a requirement list here too :

* Linux Operating System
* Root access to your system
* PERL support
* IP Table Support

When you ensure that you have everything on this check list, you can start the process of installation. I have listed the steps of code you have to use as well.

Well... Here goes....

1) Login as root to your system
2) Download the APF version 0.9.3.3 (current) to your system.
3) Now you have to extract the tar file

Quote:
bash# tar -zxf apf-current.tar.gz
4/5) Go to the APF directory and Run the code for installation
Quote:
bash# cd apf-0.9.3_3
bash# ./install.sh
You will be alerted when the installation is complete.

Install path : /etc/apf
Config path : /etc/apf/conf.apf
Executable path : /usr/local/sbin/apf

6) Modify the APF config file according to your user defined requirements.

Quote:
bash# vi /etc/apf/conf.apf
7) Add in the ports you want to open for inbound (INGRES).

Quote:
# Common ingress (inbound) TCP ports

IG_TCP_CPORTS=" 20,21,22,25,26,53,80,110,143,443,465,993,995,2082,

2083,2086,2087,2095,2096,3306,6666"

# Common ingress (inbound) UDP ports

IG_UDP_CPORTS="21,53,465,873"

# Common ICMP (inbound) types

IG_ICMP_TYPES="3,5,11,0,30,8"
The variables mentioned above are already present in the config file. You can customize the ports.

You have to particularly instruct APF to monitor outgoing (EGRESS) ports as well.

Quote:
Change the line: EGF="0" to EGF="1"
9) Specify the outbound ports to monitor.

Quote:
# Common egress (outbound) TCP ports

EG_TCP_CPORTS="21,22,25,26,37,43,53,80,110,113,443 ,465,873,2089,3306"

# Common egress (outbound) UDP ports

EG_UDP_CPORTS="20,21,53,465,873"

# Common ICMP (outbound) types

EG_ICMP_TYPES="all"
10) Specify the ports you want to block, if any.
- The allow and deny trust files are located at:
/etc/apf/allow_hosts.rules
/etc/apf/deny_hosts.rules
You just have to list the ip's that you specifically wish to allow or deny in the respective files.

- The format of these files are line-separated addresses, IP masking is supported.
Example:
24.202.16.11
24.202.11.0/24

Save and exit - hit 'esc' :wq 'enter'

11) Start APF

Quote:
bash# /usr/local/sbin/apf -s
12) If all goes well, edit the config file and change the developer mode to 0

Quote:
bash# vi /etc/apf/conf.apf
Change DEVM="1" to DEVM="0"

Save and quit - Hit 'esc' :wq 'enter'

13) Restart APF

Quote:
bash# /usr/local/sbin/apf -r
APF is now installed and monitoring your system.

Tweaking APF

This section is strictly for professionals who may wish to try their hand at tweaking the APF settings to meet their requirements.

Like I've already mentioned before, here are the major paths to take note of -

Install path : /etc/apf
Config path : /etc/apf/conf.apf
Executable path : /usr/local/sbin/apf

Here are a few more pointers that you could use to further customize your APF firewall.


Usually APF is started at boot time.

You can run it at run time like this -
Quote:
bash# chkconfig --add apf

bash# chkconfig --level 2345 apf on
You could also remove it from autostart like this -

Quote:
bash# chkconfig --del apf
And you could enable a cron job that starts the firewall sometime after runtime.


You could DOS protect your system as well.

Quote:
Change value of USE_AD (in /etc/apf/conf.apf) to 0/1 to disable or enable

[0 = Disabled / 1 = Enabled]
=> In additon to specifying the ports and ip's , you could also specify the protocols.

Advanced trust usage :

The trust rules can be made in advanced format with 4 options(proto:flowort:ip);

protocol: [packet protocol tcp/udp]

flow in/out: [packet direction, inbound or outbound]

s/d=port: [packet source or destination port]

s/d=ip(/xx) [packet source or destination address, masking supported]

Flow assumed as Input if not defined. Protocol assumed as TCP if not defined.
When defining rules with protocol, flow is required.
Quote:
proto:flow:[s/d]=port:[s/d]=ip(/mask)



s - source , d - destination , flow - packet flow in/out



Examples:

inbound to destination port 22 from 24.202.16.11 -

tcp:in:d=22:s=24.202.16.11
The main 'apf' script has a few operations built in to ease the use of your firewall.
Quote:
bash #/usr/local/sbin/apf [OPTION]


-s|--start ............. load firewall policies

-r|--restart ........... flush & load firewall

-f|--flush|--stop ...... flush firewall

-l|--list .............. list chain rules

-st|--status ........... firewall status

-a HOST|--allow HOST ... add host (IP/FQDN) to allow_hosts.rules and

immediately load new rule into firewall

-d HOST|--deny HOST .... add host (IP/FQDN) to deny_hosts.rules and

immediately load new rule into firewall
Or
APF can also be started from the init script located at /etc/init.d/apf,
standard start|stop|restart arguments are accepted by this script.

Here are a few options in the APF config file /etc/apf/conf.apf .
Quote:
- Option: DEVM="1"

Definition: APF comes default in dev. mode; meaning the firewall rules

will be flushed every 5 minutes. This is intended to prevent you from

being locked out of your system in the event of undesired results from APF.

Set the DEVM="1" option to zero (0) once APF is operating as desired.

Do NOT! leave this option enabled on a permanent basis, or you defeat

the purpose of using a firewall.



- Option: FWPATH="/etc/apf"

Definition: Absolute install path to APF; should not be changed usually.





- Option: IF="eth0"

Definition: Network interface visable too the Internet/Intranet.



- Option: NET=`ifconfig $IF | grep inet | cut -d : -f 2 | cut -d \ -f 1`

Definition: IP Address that $IF holds; either define the IP in this value

or leave it as-is to autodetect.



- Option: IPTLOG="/var/log/apf_log"

Definition: Location that APF should log status information to.



- Option: DROP_LOG="1"

Definition: Control toggle to enable/disable netfilter kernel log chains.

These chains appear in the default syslog kernel log; /var/log/messages.



- Option: LRATE="60"

Definition: Limiting toggle to increase or decrease the max iptables

logging events per/minute. This should be left high but may be decreased

to preserve disk space and logging overhead.



- Option: EGF="0"

Definition: Toggle on or off the egress packet filtering; when off APF will

operate as traditional older versions did with just input filtering.

[0 = Disabled / 1 = Enabled]



- Option: USE_DS="0"

Definition: DShield.org's "block" list of top networks that have exhibited

suspicious activity. [0 = Disabled / 1 = Enabled]
Hope this article helps you install, configure and customize APF firewall for your CPanel system.
__________________


--------------
Best Regards,
eUKScott
Business Hosting || VPS Hosting || eUKhost Knowledgebase
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:42.

 

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

Business Web Hosting
100% uptime Hosting

Cpanel Hosting
cPanel Shared Hosting

Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

Customer Testimonials
eUK Customer Testimonials


knowledgebase articles

eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting


popular blog categories


Web Hosting
Website Hosting articles

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles

Web Hosting
Web Hosting Service