[CentOS] OpenVZ – container based virtualization quick guide. Part 2


In this guide, we will be exploring how to use the tools which come with OpenVZ and setup a internet facing container/vm. This part of the guide also assumes you have followed part 1 to setup the container already and have a working environment.

In part 1, we setup a CentOS container which we could enter/exit but we didn’t do anything else on the network. What we want to do is set it up so we have the ability to bridge our hosts’ network and define static IP for network interface.


yum install bridge-utils

[root@tooncent ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5761 Gigabit Ethernet PCIe
DEVICE=eth0
ONBOOT=yes
BRIDGE=bridge0

[root@tooncent ~]# cat /etc/sysconfig/network-scripts/ifcfg-bridge0
DEVICE=bridge0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DHCP_HOSTNAME="tooncent.com"

/etc/init.d/network restart

[root@tooncent ~]# cat ifcfg-veth101.0
# Broadcom Corporation NetXtreme BCM5761 Gigabit Ethernet PCIe
DEVICE=veth101.0
ONBOOT=yes
BRIDGE=bridge0

vzctl set 101 --netif_add eth0 --save
echo '
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
' > /vz/private/101/etc/sysconfig/network-scripts/ifcfg-eth0

After this just start and you should be good to go.


One Response to “ [CentOS] OpenVZ – container based virtualization quick guide. Part 2 ”

  1. Stu
    December 7th, 2011 | 3:56 am

    The “read more” link that your blog adds to copied text is really rather annoying when you’re copying commands into a terminal. Maybe you’d consider turning it off?

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image