<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dennis henry &#187; OpenVZ</title>
	<atom:link href="http://dennishenry.net/category/linux/openvz/feed/" rel="self" type="application/rss+xml" />
	<link>http://dennishenry.net</link>
	<description>ramblings of an IT professional</description>
	<lastBuildDate>Mon, 26 Sep 2011 16:50:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Allocate x IPs to OpenVZ VEs</title>
		<link>http://dennishenry.net/2011/05/02/allocate-x-ips-to-openvz-ves/</link>
		<comments>http://dennishenry.net/2011/05/02/allocate-x-ips-to-openvz-ves/#comments</comments>
		<pubDate>Mon, 02 May 2011 15:52:57 +0000</pubDate>
		<dc:creator>dennis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[additions]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ip]]></category>

		<guid isPermaLink="false">http://dennishenry.net/?p=161</guid>
		<description><![CDATA[I ran into an interesting issue today where we had a client migrating to us that needed us to allocated X IPs to each VPS on a node he had with us. X ranged from 1 IP to up to 12 per VE so I wrote a script that took three input files (one with available IPs [newips], one with VEIDs [veids], and one  [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an interesting issue today where we had a client migrating to us that needed us to allocated X IPs to each VPS on a node he had with us. X ranged from 1 IP to up to 12 per VE so I wrote a script that took three input files (one with available IPs [newips], one with VEIDs [veids], and one with the number of IPs each VEID was allocated [numips]) and doled out the IPs as needed. Here is the result:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">r</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">k</span>=<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> veids<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">numips</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$k</span>&quot;</span>p numips<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #007800;">c</span>=<span style="color: #000000;">1</span>; c<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #007800;">$numips</span>; <span style="color: #c20cb9; font-weight: bold;">c++</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
          <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #007800;">ip</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$r</span>&quot;</span>p newips<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Add <span style="color: #007800;">$ip</span> to <span style="color: #007800;">$i</span>&quot;</span>
                vzctl <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">--ipadd</span> <span style="color: #007800;">$ip</span> <span style="color: #660033;">--save</span>
                <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">r</span>=r+<span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">k</span>=k+<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>Hopefully this will help any others who run into a similar issue.</p>
<p>Have a great day!</p>
]]></content:encoded>
			<wfw:commentRss>http://dennishenry.net/2011/05/02/allocate-x-ips-to-openvz-ves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Issues &#8211; No Networking on new OpenVZ VPS</title>
		<link>http://dennishenry.net/2011/03/23/common-issues-no-networking-on-new-openvz-vps/</link>
		<comments>http://dennishenry.net/2011/03/23/common-issues-no-networking-on-new-openvz-vps/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 22:42:21 +0000</pubDate>
		<dc:creator>dennis</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Common Issues]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[resolv.conf]]></category>
		<category><![CDATA[venet0]]></category>

		<guid isPermaLink="false">http://dennishenry.net/?p=129</guid>
		<description><![CDATA[Hello all,
Today I ran into an interesting issue where a VPS had no networking either inbound or outbound after setup. This is the error that would present when restarting network via init.d:

Bringing up interface venet0:
SIOCADDRT: Network is unreachable
SIOCADDRT: Network is unreachable

This  [...]]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>Today I ran into an interesting issue where a VPS had no networking either inbound or outbound after setup. This is the error that would present when restarting network via init.d:</p>
<pre>
Bringing up interface venet0:
SIOCADDRT: Network is unreachable
SIOCADDRT: Network is unreachable
</pre>
<p>This issue also presented in that cPanel licenses could not activate not could any ping or host commands work properly. I eventually narrowed down the issue to the fact that the IPs that had been added to the VPS were not properly set to ARP by checking with the following command (run on the node):</p>
<pre>
arp | grep [INSERT IP HERE]
</pre>
<p>In order to resolve this, all I needed to do was add the arp entries for the IPs on the actual virtual environment by running the following commands on the node:</p>
<pre>
arp -s [INSERT IP HERE] `ifconfig eth0 | grep eth0 | awk '{print $5}'` pub
</pre>
<p>Make sure you run the command above for every IP on the VPS. This resolved the issue and all networking started working again properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://dennishenry.net/2011/03/23/common-issues-no-networking-on-new-openvz-vps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple IPTables OpenVZ Setup</title>
		<link>http://dennishenry.net/2010/08/02/simple-iptables-openvz-setup/</link>
		<comments>http://dennishenry.net/2010/08/02/simple-iptables-openvz-setup/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 21:02:28 +0000</pubDate>
		<dc:creator>dennis</dc:creator>
				<category><![CDATA[IPTables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[iptables]]></category>

		<guid isPermaLink="false">http://dennishenry.net/?p=81</guid>
		<description><![CDATA[So after looking and failing to find a good article on how to describe the simple process to set up IPTables on an OpenVZ server, I figured I would write one here. The process is incredibly simple and can be broken down into 3 steps:

Empty out the contents of /etc/sysconfig/iptables
cat ""   [...]]]></description>
			<content:encoded><![CDATA[<p>So after looking and failing to find a good article on how to describe the simple process to set up IPTables on an OpenVZ server, I figured I would write one here. The process is incredibly simple and can be broken down into 3 steps:</p>
<ol>
<li>Empty out the contents of /etc/sysconfig/iptables
<pre>cat "" > /etc/sysconfig/iptables</pre>
</li>
<li>Use the following line in /etc/sysconfig/iptables-config:
<pre>IPTABLES_MODULES="ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"</pre>
</li>
<li>Use the following line in /etc/vz/vz.conf: 
<pre>IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state"</pre>
</li>
</ol>
<p>After ensuring these three things, just stop both vz and iptables, start iptables, then start vz. You should then be able to use iptables within a virtualized container.</p>
]]></content:encoded>
			<wfw:commentRss>http://dennishenry.net/2010/08/02/simple-iptables-openvz-setup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scripting IP additions in OpenVZ</title>
		<link>http://dennishenry.net/2010/04/07/scripting-ip-additions-in-openvz/</link>
		<comments>http://dennishenry.net/2010/04/07/scripting-ip-additions-in-openvz/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 20:27:43 +0000</pubDate>
		<dc:creator>dennis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[assign ip addresses]]></category>

		<guid isPermaLink="false">http://dennishenry.net/?p=49</guid>
		<description><![CDATA[So I just had an interesting issue where I was trying to add 60 IPs to 30 OpenVZ instances, 2 IPs per node. I came up with the following script to do so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
for i in `vzlist -a &#124; grep -v CTID &#124; awk '{print $1}'`
do
     let k=0
     for j in `cat  [...]]]></description>
			<content:encoded><![CDATA[<p>So I just had an interesting issue where I was trying to add 60 IPs to 30 OpenVZ instances, 2 IPs per node. I came up with the following script to do so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>vzlist <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> CTID <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">k</span>=<span style="color: #000000;">0</span>
     <span style="color: #000000; font-weight: bold;">for</span> j <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>ips<span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #000000; font-weight: bold;">do</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$k</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
          <span style="color: #000000; font-weight: bold;">then</span>
               vzctl <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">--ipadd</span> <span style="color: #007800;">$j</span> <span style="color: #660033;">--save</span>
               <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">k</span>=k+<span style="color: #000000;">1</span>
          <span style="color: #000000; font-weight: bold;">else</span>
               <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'1,2d'</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>ips
               <span style="color: #7a0874; font-weight: bold;">break</span>
          <span style="color: #000000; font-weight: bold;">fi</span>
     <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>The main things to note here are the following:</p>
<ul>
<li>When assigning a variable a value in a for loop, you need to use &#8220;let&#8221; before declaring it</li>
<li>SED can be used to remove lines just as it can be used to add and replace items in lines</li>
<li>Break is not something to be afraid of!</li>
</ul>
<p>In any case, this script might be handy for others trying to perform similar tasks so I&#8217;ll just leave it here. Feel free to modify and use this code as you please <img src='http://dennishenry.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Let me know if you have any optimizations you can think of in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://dennishenry.net/2010/04/07/scripting-ip-additions-in-openvz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

