Difference between revisions of "Adding ethernet interface to openVZ container"
(Created page with "=Adding ethernet interface (eth0, eth1, etc.) to container= To add ethernet interface to container use command: <pre> vzctl set <CID> --netif_add <ifname> --save </pre> where...") |
(No difference)
|
Revision as of 14:21, 23 November 2012
Adding ethernet interface (eth0, eth1, etc.) to container
To add ethernet interface to container use command:
vzctl set <CID> --netif_add <ifname> --save
where <ifname> can be eth0, eth1 etc.
When the interface is added to container a corresponding interface with name such as veth<CID>.<n> where n is 0 for eth0, 1 for eth1, etc. is automatically added in base host. In base host this veth* interface should then be added to a bridge so that packets sent to eth0, eth1 etc. in container can be forwarded via veth*.0 or veth*.1 through bridges to desired destinations.
When interfaces are added in this manner, the corresponding interface configuration file should be created and network service should be enabled on start-up. To enable network service on start-up use:
service network start
To configure static IPs for container using interface, say eth0, use following configuration as '/etc/sysconfig/network-scripts/ifcfg-eth0'
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=<IP address> NETMASK=<Netmask> GATEWAY=<Default Gateway> DNS1=<Local recursive DNS IP> NM_CONTROLLED=no