Editing Using private IPs for Hardware Nodes

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
{{Legacy}}
 
 
 
This article describes how to assign public IPs to containers running on OVZ Hardware Nodes in case you have a following network topology:
 
This article describes how to assign public IPs to containers running on OVZ Hardware Nodes in case you have a following network topology:
  
 
[[Image:PrivateIPs_fig1.gif|An initial network topology]]
 
[[Image:PrivateIPs_fig1.gif|An initial network topology]]
 
== Using a spare IP in the same range ==
 
If you have a spare IP to use, you could assign this as a subinterface and use this as nameserver:
 
 
<pre>[HN] ifconfig eth0:1 *.*.*.*
 
[HN] vzctl set 101 --nameserver *.*.*.*</pre>
 
  
 
== Prerequisites ==
 
== Prerequisites ==
Line 26: Line 18:
  
 
=== Hardware Node configuration ===
 
=== Hardware Node configuration ===
 
{{Warning|if you are '''configuring''' the node '''remotely''' you '''must''' prepare a '''script''' with the below commands and run it in background with the redirected output or you'll '''lose the access''' to the Node.}}
 
  
 
==== Create a bridge device ====
 
==== Create a bridge device ====
Line 45: Line 35:
 
  [HN]# ip route add default via 10.0.0.1 dev br0
 
  [HN]# ip route add default via 10.0.0.1 dev br0
 
   
 
   
 
+
{{Warning|if you are '''configuring''' the node '''remotely''' you '''must''' prepare a '''script''' with the above commands and run it in background with the redirected output or you'll '''lose the access''' to the Node.}}
  
 
==== A script example ====
 
==== A script example ====
Line 133: Line 123:
 
==== Edit the container's configuration ====
 
==== Edit the container's configuration ====
 
Add these parameters to the <code>/etc/vz/conf/$CTID.conf</code> file which will be used during the network configuration:
 
Add these parameters to the <code>/etc/vz/conf/$CTID.conf</code> file which will be used during the network configuration:
* Add <code>VETH_IP_ADDRESS="IP/MASK"</code> (a container can have multiple IPs separated by spaces)
+
* Add/change <code>CONFIG_CUSTOMIZED="yes"</code> (indicates that a custom
 +
  script should be run on a container start)
 +
* Add <code>VETH_IP_ADDRESS="IP/MASK"</code> (a container can have multiple
 +
  IPs separated by spaces)
 
* Add <code>VE_DEFAULT_GATEWAY="CT DEFAULT GATEWAY"</code>
 
* Add <code>VE_DEFAULT_GATEWAY="CT DEFAULT GATEWAY"</code>
* Add <code>BRIDGEDEV="BRIDGE NAME"</code> (a bridge name to which the container veth interface should be added)
+
* Add <code>BRIDGEDEV="BRIDGE NAME"</code> (a bridge name to which the
 +
  container veth interface should be added)
  
 
An example:
 
An example:
 
<pre>
 
<pre>
 
# Network customization section
 
# Network customization section
 +
CONFIG_CUSTOMIZED="yes"
 
VETH_IP_ADDRESS="85.86.87.195/26"
 
VETH_IP_ADDRESS="85.86.87.195/26"
 
VE_DEFAULT_GATEWAY="85.86.87.193"
 
VE_DEFAULT_GATEWAY="85.86.87.193"
Line 228: Line 223:
 
exit 0
 
exit 0
 
</pre>
 
</pre>
<p><small>Note: this script can be easily extended to work for multiple triples &lt;bridge, ip address, veth device&gt;, see http://sysadmin-ivanov.blogspot.com/2008/02/2-veth-with-2-bridges-on-openvz-at.html </small></p>
+
<p><small>Note: this script can be easily extended to work for multiple triples &lt;bridge, ip address, veth device&gt;, see http://vireso.blogspot.com/2008/02/2-veth-with-2-brindges-on-openvz-at.html </small></p>
  
 
==== Make the script to be run on a container start ====
 
==== Make the script to be run on a container start ====
Line 241: Line 236:
  
 
==== Create On-umount script for remove HW → CT route(s) ====
 
==== Create On-umount script for remove HW → CT route(s) ====
which should be called each time a container with VEID (<code>/etc/vz/conf/$VEID.umount</code>), or any container (<code>/etc/vz/conf/vps.umount</code>) is stopped.
+
which should be called each time a container with VEID (<code>/etc/sysconfig/vz/$VEID.umount</code>), or any container (<code>/etc/sysconfig/vz/vps.umount</code>) is stoped.
  
 +
On a Debian system you can have per VE mount/umount scripts /etc/vz/conf/${VEID}.{mount|umount}
 +
or mount/umount scripts which all VEs will run /etc/vz/conf/vps.{mount|umount}
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
# /etc/vz/conf/$VEID.umount or /etc/vz/conf/vps.umount
+
# /etc/sysconfig/vz/$VEID.umount or /etc/sysconfig/vz/vps.umount
 
# a script to remove routes to container with veth-bridge from bridge  
 
# a script to remove routes to container with veth-bridge from bridge  
  
Line 271: Line 268:
 
</pre>
 
</pre>
  
{{Note|The script should be executable (chmod +x /etc/vz/conf/vps.umount)}}
+
{{Note|The script should be executable (chmod +x /etc/sysconfig/vz/vps.umount)}}
  
 
==== Setting the route CT → HN ====
 
==== Setting the route CT → HN ====

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: