Common Networking HOWTOs

From OpenVZ Virtuozzo Containers Wiki
Revision as of 15:50, 12 June 2008 by Blueroomhosting (talk | contribs) (Added to HOWTO and Networking categories)
Jump to: navigation, search

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)

This is a stub.

Public VEs (with their own IP addresses)

Static addresses

This is a stub.

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:

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.

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.

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

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

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

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

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

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

[host-node]# ifconfig veth101.0 0
[host-node]# brctl addif br0 veth101.0

Finally, the network should be fully in place, so run the DHCP client inside the VE

[host-node]# vzctl enter 101
101# dhcpcd venet0:0