Optimising Security settings on VPS account - Part 1

onelove

New Member
Hello,

I'm working on tightening the security settings on my vps and have enabled my firewall in the VZPP as the first step. I will post all the steps I am going to take to optimise my account, as I go through them, so that this becomes a resource for other members of the community.

Some questions...

1)I enabled the firewall that's built into virtuozzo. Is APF (advanced policy firewall : http://rfxnetworks.com/apf.php ) necessary after enabling the VZ firewall through the VZPP?

2) I read about mod_security (http://www.modsecurity.org) . Will you be able to install this for me with the basic settings?

3) I would like to limit connections to mysql from only 127.0.0.0 . Is this advisable? I don't intend on connecting to mysql dbs from external sources...only from accounts on the vps.
 
I'd advice to go with APF if you're looking for firewall protection. VZPP provides only very basic iptables management and it is not very easy to manage iptables rules through it. Just switch firewall management in VZPP to advanced / allow and install APF.

I run a search on DA forums and found the following how to which explains how to install mod_security: http://www.directadmin.com/forum/showthread.php?threadid=11125
Feel free to submit a ticket if you need our assistance with this

Sure, to do this you can add the "bind-address=127.0.01" line into the [mysqld] section of your /etc/my.cnf

Regards,
Paul
 
Just switch firewall management in VZPP to advanced / allow and install APF.
One thing about AFP is that it is geared for a system that you have full control over. The firewall component could use some edits, like removing the loading of sysctl.rules from firewall (can't modify the running kernel under VZ). There's probably more; it needs a proper auditing. But it has a pretty complete set of rules that include some logging.

I've seen KISS Firewallrecommended in a few places. It also has some sysctl stuff that needs to be removed, and no logging enabled. Personally, I'd like to spend some time here dissecting APF's firewall script, and get the specific ports for DirectAdmin (and perhaps cPanel and Plesk as well) properly documented.
 
I have APF up and running now, and no users on the VPS have complained yet (after being informed about the firewall change and asked to yell if they saw anything) so maybe I got the right set of ports covered. But I'd like to generate a fairly canonical list of ports to set APF to use for certain, plus an optional set for common applications that are "rare enough", if you will, to make it them not enabled by default.

Here are my settings; please comment.

# Common ingress (inbound) TCP ports
IG_TCP_CPORTS="21,23,25,80,110,143,443,587,2200,2222,6000_7000,61001_65535"

# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="21,53,3784,8000,8050"

# Egress filtering [0 = Disabled / 1 = Enabled]
EGF="1"

# Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,22,25,37,43,53,80,110,443,2200,2222"

# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53,3784,8000,8005,8050"

I'm not sure about the ports in the 8000 range; saw them referenced in a DA-specfic APF setup but I need to remove them for further testing.
 
Are you perhaps using a different control panel? Any reason why you may have left out some of the above ports.
I do use DirectAdmin, fer sure. Wasn't about to pay for an extra 128MB just to make cPanel happy. ;-)

I used the URL you pointed at as a reference, but after looking up some of the ports in the privileged range I determined they weren't pertinent to my setup. I figured the "587953" should have been "587,953" but only saw a need for 587 for exim. The ones in the 8000 range I have no idea if they're really used by DA or not. And those specific high ports are also unknowns to me; perhaps they're used by DA for some purpose, but I was able to tell DA to do an update last night and it was successful in doing the upgrade. Makes me think they might not be needed.

But that's why I'd like to document each and every port that's opened up in the firewall config; I hate just trying things until they work. Having extra ports opened up doesn't make things not work, and I know in my case I'm most likely to find out I made a mistake by finding I've been hacked.
 
Thread moved to Directadmin tutorials forum though some of this information is very helpful for other CP's as well.

Thanks!
 
Top