Article ID: 112961, created on Dec 7, 2011, last review on Jun 17, 2016

  • Applies to:
  • Virtuozzo
  • Virtuozzo containers for Linux
  • Virtuozzo hypervisor

Symptoms

This article explains how to assign a container with two NICs attached to different networks.

This configuration is required in cases where a container needs to have separate private and public network access with appropriate routing rules, e.g., when FrontNet is used for external access and BackNet is used for internal traffic.

Resolution

The example below illustrates how to connect a container to bridged FrontNet and BackNet networks:

  1. Create two bridged networks:

    ~# vznetcfg net new FrontNet
    ~# vznetcfg net new BackNet
    
  2. Find out which hardware NIC corresponds to which network:

    ~# ip a l
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
            valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 48:5b:39:19:6d:66 brd ff:ff:ff:ff:ff:ff
        inet 192.168.30.40/24 brd 192.168.30.255 scope global eth0
            valid_lft forever preferred_lft forever
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 48:5b:39:19:6d:68 brd ff:ff:ff:ff:ff:ff
        inet 100.200.30.40/24 brd 100.200.30.255 scope global eth1
            valid_lft forever preferred_lft forever
    
  3. Assign network interfaces to the virtual networks:

    ~# vznetcfg net addif FrontNet eth1
    ~# vznetcfg net addif BackNet eth0
    
  4. Add two network interfaces to the container:

    ~# vzctl set CTID --save --netif_add eth0
    ~# vzctl set CTID --save --netif_add eth1
    
  5. Assign them to the corresponding networks and configure the virtual adapters:

    ~# vzctl set CTID --save --ifname eth0 --network BackNet --ipadd 192.168.30.41/24 --gw 192.168.30.1
    ~# vzctl set CTID --save --ifname eth1 --network FrontNet --ipadd 100.200.30.41/24
    

NOTE: The "--gw" option specifies the default gateway setting, and generally it should be set only for one adapter. Set the most preferable routing scheme according to your needs.

Search Words

two networks

vznetcfg

bridged network

Network Type

two adapters

.

multihome

routing problems

Shared VPSs into Hardware Nodes

Add network interface

network

Virtual network

Preparations to upgrade to 6.0

virtuozzo networking

bridged

e8e50b42231236b82df27684e7ec0beb d02f9caf3e11b191a38179103495106f 2897d76d56d2010f4e3a28f864d69223 0dd5b9380c7d4884d77587f3eb0fa8ef a26b38f94253cdfbf1028d72cf3a498b

Email subscription for changes to this article
Save as PDF