Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Common Networking HOWTOs

2,225 bytes added, 15:43, 12 June 2008
New page: 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. == Private VEs (not directly visible ...
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.

== Private VEs (not directly visible from the LAN) ==

== Public VEs (with their own IP addresses) ==

=== Static addresses ===

=== DHCP supplied addresses ===

For this section the following assumptions have been made:

* The host is connected to the LAN by eth0, and also uses DHCP.
* The DHCP server is another machine on the LAN.

To make the VEs truly part of the LAN it is best to create a bridge that binds them, and the LAN, together.
Configuring the host to use a bridge when it boots is distribution specific and beyond the scope of this article.
It can be done from the command line as follows:

<pre>
bring eth0 down (distro dependent)
[host-node]# /etc/init.d/net.eth0 down
-- or --
[host-node]# ifdown eth0
etc.

create the bridge
[host-node]# brctl addbr br0

add eth0
[host-node]# brctl addif br0 eth0

each bridge interface must be up, but with no ip address
[host-node]# ifconfig eth0 0

now run DHCP for the bridge (client dependent)
[host-node]# dhcpcd br0
-- or --
[host-node]# dhclient3 br0
etc.
</pre>

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.

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.

<pre>
[host-node]# ifconfig eth0
...
HWaddress 00:12:34:56:78:9B
...
</pre>

Now a new mac address must be invented, preferably higher than eth0's address.

<pre>
[host-node]# easymac.sh -R
00:12:34:56:78:9A
</pre>

The new veth device can be assigned using the above information.

<pre>
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save
</pre>

Now add the new device to the bridge and bring it up on the host.

<pre>
[host-node]# ifconfig veth101.0 0
[host-node]# brctl addif br0 veth101.0
</pre>

Finally, the network should be fully in place, so run the DHCP client inside the VE
<pre>
[host-node]# vzctl enter 101
101# dhcpcd venet0:0
</pre>