18
edits
Changes
Added specifics of iptables usage within a container. The method differs from securing a physical server!
# [sudo] apt-get install vzprocps vzdump
== Secure it ==
If you want to secure your container with individual firewall rules (instead or additionally to securing the host node) then you must run iptables inside the container. This works slightly different than on a physical server. So make sure that you check that iptables rules are indeed applied as expected inside the container.
Iptables modules required by the container must be specified in the general vz.conf file or the vzXXX.conf file of the container.
Add the following line into vz.conf to activate the respective iptables modules for all containers.
IPTABLES="ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS"
[[http://wiki.debian.org/DebianFirewall][Configure]] your iptable rules inside the container.
{{Warning|Note that iptables rules inside the container are not applied automatically as on a physical server by starting the iptables module! Follow the instructions below}}
To make sure the iptables rules are applied on a startup/reboot we'll create a new file:
nano /etc/network/if-pre-up.d/iptables
Add these lines to it:
#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules
The file needs to be executable so change the permissions:
chmod +x /etc/network/if-pre-up.d/iptables
Start iptables
/etc/init.d/iptables start
If the startup shows errors then you have probably not activated the needed iptables modules. See above.
Check inside the container that your iptables rules are indeed applied:
iptables -L
If the rules do not show up as you would expect on a physical server then you might not have activated the needed iptables modules.
== Start it! ==
to create a first container and do some
[[basic operations in OpenVZ environment]]. Read the [[download:doc/OpenVZ-Users-Guide.pdf]], browse this wiki.
[[Category: HOWTO]]
[[Category: Debian]]
[[Category: Installation]]