<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Guaka</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Guaka"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Guaka"/>
	<updated>2026-04-11T09:26:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=23413</id>
		<title>User:Guaka</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=23413"/>
		<updated>2022-02-09T16:42:08Z</updated>

		<summary type="html">&lt;p&gt;Guaka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://guaka.org/]&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=7220</id>
		<title>User:Guaka</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=7220"/>
		<updated>2009-04-09T16:15:50Z</updated>

		<summary type="html">&lt;p&gt;Guaka: My contributions on this wiki are public domain.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://guaka.org/ Kasper Souren]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
My contributions on this wiki are public domain.&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Using_NAT_for_container_with_private_IPs&amp;diff=7215</id>
		<title>Talk:Using NAT for container with private IPs</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Using_NAT_for_container_with_private_IPs&amp;diff=7215"/>
		<updated>2009-04-08T14:03:36Z</updated>

		<summary type="html">&lt;p&gt;Guaka: &amp;quot;Usually you supply public IP addresses to your containers&amp;quot;? How? ~~~~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was stumbling a lot with the configuration where allowing access to a service from outside, because I assumed that after adding the iptables DNAT rule, I could test the rule from the hardware node. The rule only works for packets send from outside.&lt;br /&gt;
&lt;br /&gt;
I added some text about it now, but maybe someone could rephrase it more nicely.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;For OpenVZ kernels later than 2.6.8, connection tracking &lt;br /&gt;
for VE0 is enabled by default. However, make sure there is no line like &lt;br /&gt;
&lt;br /&gt;
options ip_conntrack ip_conntrack_disable_ve0=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It seems to me that here must be =0 ??? Or not?&lt;br /&gt;
&lt;br /&gt;
[[User:Shaplov|Shaplov]] 10:27, 23 June 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;quot;Usually you [[supply public IP addresses to your containers]]&amp;quot;? How? [[User:Guaka|Guaka]] 14:03, 8 April 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Container&amp;diff=7214</id>
		<title>Talk:Container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Container&amp;diff=7214"/>
		<updated>2009-04-08T14:00:35Z</updated>

		<summary type="html">&lt;p&gt;Guaka: New page: About the note, is it okay to replace VE by container in existing articles? ~~~~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;About the note, is it okay to replace VE by container in existing articles? [[User:Guaka|Guaka]] 14:00, 8 April 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Common_Networking_HOWTOs&amp;diff=7213</id>
		<title>Common Networking HOWTOs</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Common_Networking_HOWTOs&amp;diff=7213"/>
		<updated>2009-04-08T13:59:37Z</updated>

		<summary type="html">&lt;p&gt;Guaka: VE?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;While other pages do a great job of going into the details of veth and venet networking, this page is all about getting the results you want quickly.&lt;br /&gt;
&lt;br /&gt;
== Private VEs (not directly visible from the LAN) ==&lt;br /&gt;
&lt;br /&gt;
When starting with a new [[VE]] that should not be directly visible on the LAN it is important to choose an appropriate IP address. By running &amp;quot;ifconfig -a&amp;quot; on the host it is possible to see all the networks the host is connected to. The VE should reside on a a new private network, choosing one of the 192.168.X.Y/24 subnets is a good choice.&lt;br /&gt;
&lt;br /&gt;
For example, on a host which is already on a 192.168.1.0/24 subnet then the 192.168.2.0/24 subnet would be a reasonable choice (unless the host is already on that subnet too).&lt;br /&gt;
&lt;br /&gt;
In these examples the host has eth0 with address 192.168.1.53, and 192.168.2.0/24 is free so we will give the VE 192.168.2.1. The VE (101) is assumed to be freshly created and started, with no networking currently set up.&lt;br /&gt;
&lt;br /&gt;
=== Venet ===&lt;br /&gt;
&lt;br /&gt;
Venet routed networking is probably the simplest to set up, simply add the IP address to the VE:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --ipadd 192.168.2.1 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After this the host should be able to ping the VE.&lt;br /&gt;
&lt;br /&gt;
To allow the VE to access the rest of the LAN we must enable forwarding and masquerading, as all activity on the LAN must look like it is coming directly from host (with its IP address).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
[host-node]# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Veth ===&lt;br /&gt;
&lt;br /&gt;
This is a stub&lt;br /&gt;
&lt;br /&gt;
== Public VEs (with their own IP addresses) ==&lt;br /&gt;
&lt;br /&gt;
=== Static addresses ===&lt;br /&gt;
&lt;br /&gt;
This is very similar to using private addresses, except there is no need for masquerading and the VE will be visible to others on the LAN.&lt;br /&gt;
&lt;br /&gt;
In this example the host has eth0 with address 192.168.1.53, and the VE will be set up with 192.168.1.101. The VE (101) is assumed to be freshly created and started, with no networking currently set up.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --ipadd 192.168.1.101 --save&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== DHCP supplied addresses ===&lt;br /&gt;
&lt;br /&gt;
For this section the following assumptions have been made:&lt;br /&gt;
&lt;br /&gt;
* The host is connected to the LAN by eth0, and also uses DHCP.&lt;br /&gt;
* The DHCP server is another machine on the LAN.&lt;br /&gt;
&lt;br /&gt;
To make the VEs truly part of the LAN it is best to create a bridge that binds them, and the LAN, together.&lt;br /&gt;
Configuring the host to use a bridge when it boots is distribution specific and beyond the scope of this article.&lt;br /&gt;
It can be done from the command line as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bring eth0 down (distro dependent)&lt;br /&gt;
[host-node]# /etc/init.d/net.eth0 down&lt;br /&gt;
-- or --&lt;br /&gt;
[host-node]# ifdown eth0&lt;br /&gt;
etc.&lt;br /&gt;
&lt;br /&gt;
create the bridge&lt;br /&gt;
[host-node]# brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
add eth0&lt;br /&gt;
[host-node]# brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
each bridge interface must be up, but with no ip address&lt;br /&gt;
[host-node]# ifconfig eth0 0&lt;br /&gt;
&lt;br /&gt;
now run DHCP for the bridge (client dependent)&lt;br /&gt;
[host-node]# dhcpcd br0&lt;br /&gt;
-- or --&lt;br /&gt;
[host-node]# dhclient3 br0&lt;br /&gt;
etc.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage the host should be present on the LAN (test with pings), much as it was before, only now it is using a bridge that can have other interfaces attached to it.&lt;br /&gt;
&lt;br /&gt;
Starting with a new VE (101), which should have no networking  configured and be running, it is now necessary to add a veth device. First the mac address of eth0 must be determined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig eth0&lt;br /&gt;
...&lt;br /&gt;
HWaddress 00:12:34:56:78:9B&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now a new mac address must be invented, preferably higher than eth0's address.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# easymac.sh -R&lt;br /&gt;
00:12:34:56:78:9A&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The new veth device can be assigned using the above information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now add the new device to the bridge and bring it up on the host.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# brctl addif br0 veth101.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, the network should be fully in place, so run the DHCP client inside the VE&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
101# dhcpcd venet0:0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=7212</id>
		<title>User:Guaka</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Guaka&amp;diff=7212"/>
		<updated>2009-04-08T13:58:41Z</updated>

		<summary type="html">&lt;p&gt;Guaka: New page: [http://guaka.org/ Kasper Souren]&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://guaka.org/ Kasper Souren]&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Setting_up_an_iptables_firewall&amp;diff=7211</id>
		<title>Setting up an iptables firewall</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Setting_up_an_iptables_firewall&amp;diff=7211"/>
		<updated>2009-04-08T13:54:41Z</updated>

		<summary type="html">&lt;p&gt;Guaka: HN?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document consists of two parts. The first is setting up a firewall (using iptables) on the HN, which will restrict traffic to the containers. The effect would emulate, as far as the containers and their customers are concerned, an external hardware firewall controlled by the sysadmin. The second is setting up a firewall that protects the [[HN]] itself but still allows traffic to the containers, thus allowing individual containers to define their own iptables.&lt;br /&gt;
&lt;br /&gt;
While the firewalls shown here can be accomplished using iptables manually (or using Fedora core's iptables service), the methods presented here are especially modular and easy to modify. This is important when you have 20+ containers and a lot of other things to be doing...&lt;br /&gt;
&lt;br /&gt;
The scripts and pathnames given here are for Fedora Core 6, though they can probably be applied to most similar SysV-like systems with little modification.&lt;br /&gt;
&lt;br /&gt;
== A little background ==&lt;br /&gt;
&lt;br /&gt;
On our systems, we use the HN to provide privileged services which are not appropriate for access by the containers. For example, the HN acts as a backup server, runs Nagios for health monitoring, has a webserver for managing the 3ware RAID controller, etc. The containers are leased to customers, who can't entirely be trusted, especially if they get hacked. As such, our scenario is one in which the HN must be protected from all access (even from the containers) except for a few trusted hosts (e.g. my home-office).&lt;br /&gt;
&lt;br /&gt;
The exception to this is the nameserver, which we want open to the world. We use it as a caching nameserver for our containers and also to host DNS for a few customer domain.&lt;br /&gt;
&lt;br /&gt;
== Setting up a HN-based firewall ==&lt;br /&gt;
&lt;br /&gt;
This setup emulates (to the containers anyway) an external hardware firewall. It protects the HN from any access and then defines what services and ports are allowed/banned for individual containers. This leaves the firewall controlled by the site administrator, not be individual containers and the hackers who've gotten into them. ;)&lt;br /&gt;
&lt;br /&gt;
First off, let's disable Fedora's existing &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; service:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
service iptables stop&lt;br /&gt;
chkconfig iptables off&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now create the new &amp;lt;code&amp;gt;firewall&amp;lt;/code&amp;gt; service. This code should be &amp;lt;code&amp;gt;/etc/init.d/firewall&amp;lt;/code&amp;gt; and then should be chmod'd 755.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# firewall      Start iptables firewall&lt;br /&gt;
# chkconfig: 2345 08 92&lt;br /&gt;
# description:  Starts, stops and saves iptables firewall&lt;br /&gt;
# This script sets up the firewall for the INPUT chain (which is for&lt;br /&gt;
# the HN itself) and then processes the config files under&lt;br /&gt;
# /etc/firewall.d to set up additional rules in the FORWARD chain&lt;br /&gt;
# to allow access to containers' services.&lt;br /&gt;
&lt;br /&gt;
. /etc/init.d/functions&lt;br /&gt;
&lt;br /&gt;
# the IP block allocated to this server&lt;br /&gt;
SEGMENT=&amp;quot;192.168.0.0/24&amp;quot;&lt;br /&gt;
# the IP used by the hosting server itself&lt;br /&gt;
THISHOST=&amp;quot;192.168.0.1&amp;quot;&lt;br /&gt;
# services that should be allowed to the HN;&lt;br /&gt;
# services for containers are configured in /etc/firewall.d/*&lt;br /&gt;
OKPORTS=&amp;quot;53&amp;quot;&lt;br /&gt;
# hosts allowed full access through the firewall,&lt;br /&gt;
# to all containers and to this server&lt;br /&gt;
DMZS=&amp;quot;12.34.56.78 90.123.45.67&amp;quot;&lt;br /&gt;
&lt;br /&gt;
purge() {&lt;br /&gt;
  echo -n &amp;quot;Firewall: Purging and allowing all traffic&amp;quot;&lt;br /&gt;
  iptables -P OUTPUT ACCEPT&lt;br /&gt;
  iptables -P FORWARD ACCEPT&lt;br /&gt;
  iptables -P INPUT ACCEPT&lt;br /&gt;
  iptables -F&lt;br /&gt;
  success ; echo&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
setup() {&lt;br /&gt;
  echo -n &amp;quot;Firewall: Setting default policies to DROP&amp;quot;&lt;br /&gt;
  iptables -P INPUT DROP&lt;br /&gt;
  iptables -P FORWARD DROP&lt;br /&gt;
  iptables -I INPUT   -j ACCEPT -m state --state ESTABLISHED,RELATED&lt;br /&gt;
  iptables -I FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED&lt;br /&gt;
  iptables -I INPUT -j ACCEPT -i lo&lt;br /&gt;
  iptables -I FORWARD -j ACCEPT --source $SEGMENT&lt;br /&gt;
  success ; echo&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;Firewall: Allowing access to HN&amp;quot;&lt;br /&gt;
  for port in $OKPORTS ; do&lt;br /&gt;
    echo -n &amp;quot;          port $port&amp;quot;&lt;br /&gt;
    iptables -I INPUT -j ACCEPT -s $SEGMENT -d $THISHOST --protocol tcp --destination-port $port&lt;br /&gt;
    iptables -I INPUT -j ACCEPT -s $SEGMENT -d $THISHOST --protocol udp --destination-port $port&lt;br /&gt;
    success ; echo&lt;br /&gt;
  done&lt;br /&gt;
  for ip in $DMZS ; do&lt;br /&gt;
    echo -n &amp;quot;          DMZ $ip&amp;quot;&lt;br /&gt;
    iptables -I INPUT   -i eth0 -j ACCEPT -s $ip&lt;br /&gt;
    iptables -I FORWARD -i eth0 -j ACCEPT -s $ip&lt;br /&gt;
    success ; echo&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  CTSETUPS=`echo /etc/firewall.d/*`&lt;br /&gt;
  if [ &amp;quot;$CTSETUPS&amp;quot; != &amp;quot;/etc/firewall.d/*&amp;quot; ] ; then&lt;br /&gt;
  echo &amp;quot;Firewall: Setting up container firewalls&amp;quot;&lt;br /&gt;
  for i in $CTSETUPS ; do&lt;br /&gt;
    . $i&lt;br /&gt;
    echo -n &amp;quot;          $CTNAME CT$CTID&amp;quot;&lt;br /&gt;
    if [ -n &amp;quot;$BANNED&amp;quot; ]; then&lt;br /&gt;
      for source in $BANNED ;  do iptables -I FORWARD -j DROP --destination $CTIP --source $source ; done&lt;br /&gt;
    fi&lt;br /&gt;
    if [ -n &amp;quot;$OPENPORTS&amp;quot; ]; then&lt;br /&gt;
      for port in $OPENPORTS ; do iptables -I FORWARD -j ACCEPT --protocol tcp --destination $CTIP --destination-port $port ; done&lt;br /&gt;
      for port in $OPENPORTS ; do iptables -I FORWARD -j ACCEPT --protocol udp --destination $CTIP --destination-port $port ; done&lt;br /&gt;
    fi&lt;br /&gt;
    if [ -n &amp;quot;$DMZS&amp;quot; ]; then&lt;br /&gt;
      for source in $DMZS ; do iptables -I FORWARD -j ACCEPT --protocol tcp --destination $CTIP --source $source ; done&lt;br /&gt;
      for source in $DMZS ; do iptables -I FORWARD -j ACCEPT --protocol udp --destination $CTIP --source $source ; done&lt;br /&gt;
    fi&lt;br /&gt;
    [ $? -eq 0 ] &amp;amp;&amp;amp; success || failure&lt;br /&gt;
    echo&lt;br /&gt;
  done&lt;br /&gt;
  fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
  start)&lt;br /&gt;
    echo &amp;quot;Starting firewall...&amp;quot;&lt;br /&gt;
    purge&lt;br /&gt;
    setup&lt;br /&gt;
    ;;&lt;br /&gt;
  stop)&lt;br /&gt;
    echo &amp;quot;Stopping firewall...&amp;quot;&lt;br /&gt;
    purge&lt;br /&gt;
    ;;&lt;br /&gt;
  restart)&lt;br /&gt;
    $0 stop&lt;br /&gt;
    $0 start&lt;br /&gt;
    ;;&lt;br /&gt;
  status)&lt;br /&gt;
    iptables -n -L&lt;br /&gt;
    ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Usage: $0 &amp;lt;start|stop|restart|status&amp;gt;&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above script can be called like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
service firewall start&lt;br /&gt;
service firewall stop&lt;br /&gt;
service firewall restart&lt;br /&gt;
service firewall status&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will set up the firewall for the HN according to the parameters you specified for OKPORTS, DMZs, etc. and then it will call each file under /etc/firewall.d and process  its configuration.&lt;br /&gt;
&lt;br /&gt;
So create a file under /etc/firewall.d The exact filename isn't important, as long as it's meaningful to you, e.g. &amp;lt;code&amp;gt;ExampleCompany&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ve12&amp;lt;/code&amp;gt; and give it content like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This file is processed by /etc/init.d/firewall&lt;br /&gt;
CTID=&amp;quot;1&amp;quot;			# the container's ID#&lt;br /&gt;
CTNAME=&amp;quot;Customer1&amp;quot;		# A human-friendly label for the container&lt;br /&gt;
CTIP=&amp;quot;192.168.1.34&amp;quot;		# the IP address for this container &lt;br /&gt;
OPENPORTS=&amp;quot;80 443&amp;quot;		# ports that should be universally opened&lt;br /&gt;
				# to the entire Internet&lt;br /&gt;
DMZS=&amp;quot;1.2.3.0/24 5.6.7.8/32&amp;quot;	# IPs and blocks that should have full access&lt;br /&gt;
				# to the container's services&lt;br /&gt;
BANNED=&amp;quot;&amp;quot;			# IPs and blocks that should be entirely&lt;br /&gt;
				# blocked from the container's services&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And there you go. Go ahead and start the firewall and check its status:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
service firewall restart&lt;br /&gt;
service firewall status&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, you can now add and edit the configurations for individual containers very easily. This method proves a lot easier to manage than Fedora's iptables-config mechamism!&lt;br /&gt;
&lt;br /&gt;
=== Debian Notes ===&lt;br /&gt;
&lt;br /&gt;
The setup above works fine for Debian as well, however /etc/init.d/functions is missing. Here is a very simple version that you can use:&lt;br /&gt;
&lt;br /&gt;
  # /etc/init.d/functions&lt;br /&gt;
  &lt;br /&gt;
  success() {&lt;br /&gt;
    echo -n &amp;quot;...success&amp;quot;&lt;br /&gt;
  } &lt;br /&gt;
  failure() {&lt;br /&gt;
    echo -n &amp;quot;...failure&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Setting up a firewall that allows per-container configuration ==&lt;br /&gt;
&lt;br /&gt;
This setup configures iptables on the HN to disallow access to all hosts, including the containers. However, it allows all traffic into the containers so they may define their own iptables rules and therefore manage their own firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
iptables -P FORWARD ACCEPT&lt;br /&gt;
iptables -F FORWARD&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will remove all rules for the FORWARD chain so all packets can pass back and forth between containers and the outside world.&lt;br /&gt;
&lt;br /&gt;
If you want to use a firewall inside a container, please load these modules BEFORE starting the container:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe xt_tcpudp&lt;br /&gt;
modprobe ip_conntrack&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not, you will get an error like this: &amp;quot;iptables: No chain/target/match by that name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If you want to use stateful firewall rules (and you should!) you will also need to make sure that 'ipt_state' is in the 'IPTABLES' option in your vz.conf file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IPTABLES=&amp;quot;ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also make sure the 'xt_state' module is loaded on the host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe xt_state&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Traffic accounting with iptables]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;/div&gt;</summary>
		<author><name>Guaka</name></author>
		
	</entry>
</feed>