64
edits
Changes
New page: This article describes how to assign public IPs to VEs running on OVZ Hardware Nodes in case you have a following network topology: [[Image:PrivateIPs_fig1.gif|An initial network topology]...
This article describes how to assign public IPs to VEs running on OVZ Hardware Nodes in case you have a following network topology:
[[Image:PrivateIPs_fig1.gif|An initial network topology]]
== Prerequisites ==
This article assumes you have already [[Quick installation|installed OpenVZ]], prepared the [[OS template cache]](s) and have [[Basic_operations_in_OpenVZ_environment|VE(s) created]]. If not, follow the links to perform the steps needed.
{{Note|don't assign an IP after VE creation.}}
<br>
== (1) An OVZ Hardware Node has the only one ethernet interface ==
(assume eth0)
=== <u>Hardware Node configuration</u> ===
==== Create a bridge device ====
<pre>[HN]# brctl addbr br0</pre>
==== Remove an IP from eth0 interface ====
<pre>[HN]# ifconfig eth0 0</pre>
==== Add eth0 interface into the bridge ====
<pre>[HN]# brctl addif br0 eth0</pre>
==== Assign the IP to the bridge ====
(the same that was assigned on eth0 earlier)
<pre>[HN]# ifconfig br0 10.0.0.2/24</pre>
==== Resurrect the default routing ====
<pre>[HN]# ip route add default via 10.0.0.1 dev br0</pre>
{{Note|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 ====
<pre>
[HN]# cat /tmp/br_add
#!/bin/bash
brctl addbr br0
ifconfig eth0 0
brctl addif br0 eth0
ifconfig br0 10.0.0.2/24
ip route add default via 10.0.0.1 dev br0
</pre>
<pre>[HN]# /tmp/br_add >/dev/null 2>&1 &</pre>
<br>
=== <u>VE configuration</u> ===
==== Start a VE ====
<pre>[HN]# vzctl start 101</pre>
==== Add a [[Virtual_Ethernet_device|veth interface]] to the VE ====
<pre>[HN]# vzctl set 101 --netif_add eth0 –save</pre>
==== Set up an IP to the newly created VE's veth interface ====
<pre>[HN]# vzctl exec 101 ifconfig eth0 85.86.87.194/26</pre>
==== Set up the default route for the VE ====
<pre>[HN]# vzctl exec 101 ip route change default via 85.86.87.192 dev eth0</pre>
==== Add the VE's veth interface to the bridge ====
<pre>[HN]# brctl addif br0 veth101.0</pre>
==== (Optional) Make HN(s) to be accessible from a VE ====
The configuration above provides following connections available:
<pre>
VE X <-> VE Y (where VE X and VE Y can locate on any OVZ HN)
VE <-> Internet
HN -> VE
</pre>
If you really need a VE to have an access to the HN(s) add an additional route rule:
<pre>[HN]# vzctl exec 101 ip route add 10.0.0.0/24 dev eth0</pre>
=== <u>The resulted OVZ Node configuration</u> ===
[[Image:PrivateIPs_fig2.gif|The resulted OVZ Node configuration]]
=== <u>Making the configuration persistent</u> (TODO) ===
A Nardware Node configuration can be done with help of ordinary initscripts configuration i suppose,<br>
while VEs configuration will require creating additional script based on [[Virtual_Ethernet_device#Making_a_veth-device_persistent|Making a veth-device persistent]] scheme.
<br>
== (2) An OVZ Hardware Node has two ethernet interfaces (TODO) ==
(assume eth0 and eth1)
[[Image:PrivateIPs_fig1.gif|An initial network topology]]
== Prerequisites ==
This article assumes you have already [[Quick installation|installed OpenVZ]], prepared the [[OS template cache]](s) and have [[Basic_operations_in_OpenVZ_environment|VE(s) created]]. If not, follow the links to perform the steps needed.
{{Note|don't assign an IP after VE creation.}}
<br>
== (1) An OVZ Hardware Node has the only one ethernet interface ==
(assume eth0)
=== <u>Hardware Node configuration</u> ===
==== Create a bridge device ====
<pre>[HN]# brctl addbr br0</pre>
==== Remove an IP from eth0 interface ====
<pre>[HN]# ifconfig eth0 0</pre>
==== Add eth0 interface into the bridge ====
<pre>[HN]# brctl addif br0 eth0</pre>
==== Assign the IP to the bridge ====
(the same that was assigned on eth0 earlier)
<pre>[HN]# ifconfig br0 10.0.0.2/24</pre>
==== Resurrect the default routing ====
<pre>[HN]# ip route add default via 10.0.0.1 dev br0</pre>
{{Note|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 ====
<pre>
[HN]# cat /tmp/br_add
#!/bin/bash
brctl addbr br0
ifconfig eth0 0
brctl addif br0 eth0
ifconfig br0 10.0.0.2/24
ip route add default via 10.0.0.1 dev br0
</pre>
<pre>[HN]# /tmp/br_add >/dev/null 2>&1 &</pre>
<br>
=== <u>VE configuration</u> ===
==== Start a VE ====
<pre>[HN]# vzctl start 101</pre>
==== Add a [[Virtual_Ethernet_device|veth interface]] to the VE ====
<pre>[HN]# vzctl set 101 --netif_add eth0 –save</pre>
==== Set up an IP to the newly created VE's veth interface ====
<pre>[HN]# vzctl exec 101 ifconfig eth0 85.86.87.194/26</pre>
==== Set up the default route for the VE ====
<pre>[HN]# vzctl exec 101 ip route change default via 85.86.87.192 dev eth0</pre>
==== Add the VE's veth interface to the bridge ====
<pre>[HN]# brctl addif br0 veth101.0</pre>
==== (Optional) Make HN(s) to be accessible from a VE ====
The configuration above provides following connections available:
<pre>
VE X <-> VE Y (where VE X and VE Y can locate on any OVZ HN)
VE <-> Internet
HN -> VE
</pre>
If you really need a VE to have an access to the HN(s) add an additional route rule:
<pre>[HN]# vzctl exec 101 ip route add 10.0.0.0/24 dev eth0</pre>
=== <u>The resulted OVZ Node configuration</u> ===
[[Image:PrivateIPs_fig2.gif|The resulted OVZ Node configuration]]
=== <u>Making the configuration persistent</u> (TODO) ===
A Nardware Node configuration can be done with help of ordinary initscripts configuration i suppose,<br>
while VEs configuration will require creating additional script based on [[Virtual_Ethernet_device#Making_a_veth-device_persistent|Making a veth-device persistent]] scheme.
<br>
== (2) An OVZ Hardware Node has two ethernet interfaces (TODO) ==
(assume eth0 and eth1)