Multiple NICs for OpenVZ containers

tuxillo

Renowned Member
Mar 2, 2010
57
6
73
Hi,

I would like to know if it's possible that a OpenVZ container could have multiple network interfaces.
If so, how to do it?

Thanks,
Antonio Huete
 
venet:
you can assign multiple IP addresses, just add them after you created the container (separated with spaces) on the GUI

veth:
via CLI (see 'man vzctl')
 
Via 'man vzctl', for veth, you should end up with something like:

vzctl set <VMID> --netif_add eth<N>,,,,vmbr<M> --save

for adding an interface eth<N> in the container <VMID> to bridge vmbr<M> in the host.

To remove eth<N> from container <VMID> trigger:

vzctl set <VMID> --netif_del eth<N> --save


Tom, what about adding support for many veth devices to the web GUI as a low priority feature request?
 
yes, I will file it.
 
Hi,

is it also possible to asssign different mac addresses for each IP?
I can't reach the second IP after a network Upgrade at the data centre.
 
This does not seem to work till after vzctl restart 111. Am I missing sometihng.
vvoice2:~# vzctl set 111 --netif_add eth1,,,,vmbr1 --save
Container does not have configured veth: eth1, skipped
Configure veth devices: veth111.1
Saved parameters for CT 111


root@steakhouse:~# ifconfig
eth0 ---Removed for forum ----

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:38 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2440 (2.4 KB) TX bytes:2440 (2.4 KB)

root@steakhouse:~# sudo ifconfig eth1 10.10.30.201/24 up
root@steakhouse:~# ifconfig
eth0 ---Removed for forum ----

eth1 Link encap:Ethernet HWaddr 00:18:51:72:27:5a
inet addr:10.10.30.201 Bcast:10.10.30.255 Mask:255.255.255.0
inet6 addr: fe80::218:51ff:fe72:275a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:3 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:38 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2440 (2.4 KB) TX bytes:2440 (2.4 KB)
root@steakhouse:~# ping 10.10.30.10
PING 10.10.30.10 (10.10.30.10) 56(84) bytes of data.
^C
--- 10.10.30.10 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

root@steakhouse:~# ping 10.10.30.13
PING 10.10.30.13 (10.10.30.13) 56(84) bytes of data.
^C
--- 10.10.30.13 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

root@steakhouse:~# arp -a
? (10.10.30.10) at <incomplete> on eth1
? (10.10.30.13) at <incomplete> on eth1
root@steakhouse:~#
 
hy everyone

i have Debian 6.0 i386 with openvz 686

i make some containers and them work good

but i wann make a container with multiple public ips to container

at server i have made bridge this is the config

Code:
root@smallhosting:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

brctl addbr br0
auto br0
iface br0 inet static
bridge_ports eth1
 address 89.42.231.180
 broadcast 89.42.231.255
 netmask 255.255.255.0
 gateway 89.42.231.1

the id of container is 113

this is conf of 113.conf

Code:
VE_ROOT="/storage/vz/root/$VEID"
VE_PRIVATE="/storage/vz/private/$VEID"
OSTEMPLATE="debian-6.0-i386-minimal"
ORIGIN_SAMPLE="basic"
HOSTNAME="test.smallhosting.ro"
NAMESERVER="193.231.169.2"
SEARCHDOMAIN="smallhosting.ro"
VETH_IP_ADDRESS="89.42.231.113"
NETIF="ifname=eth1.113,mac=00:02:04:06:08:02,host_ifname=veth113.0,host_mac=00:19:99:c4:66:87"

so i tryed a lots of times and search 2 weeks on google to read how to make this

so i tryed like this:

i installed vlan and i config interface like this

Code:
brctl addbr br0
auto br0
iface br0 inet static
bridge_ports eth1
 address 89.42.231.180
 broadcast 89.42.231.255
 netmask 255.255.255.0
 gateway 89.42.231.1

auto eth1.113
iface eth1.113 inet static
        address 89.42.231.113
        netmask 255.255.255.0
        #gateway 192.168.110.254
        #network 192.168.110.0
        broadcast 89.42.231.255
        vlan_raw_device eth1

auto eth1.124
iface eth1.124 inet static
        address 89.42.231.124
        netmask 255.255.255.0
        #gateway 192.168.110.254
        #network 192.168.110.0
        broadcast 89.42.231.255
        vlan_raw_device eth1

113.conf was this

Code:
VE_ROOT="/storage/vz/root/$VEID"
VE_PRIVATE="/storage/vz/private/$VEID"
OSTEMPLATE="debian-6.0-i386-minimal"
ORIGIN_SAMPLE="basic"
HOSTNAME="test.smallhosting.ro"
NAMESERVER="193.231.169.2"
SEARCHDOMAIN="smallhosting.ro"
VETH_IP_ADDRESS="89.42.231.113/24;89.42.231.124/24"
#BRIDGEDEV="br0"
NETIF="ifname=eth1.113,mac=00:02:04:06:08:02,host_ifname=veth113.0,host_mac=00:19:99:c4:66:87;ifname=eth1.124,mac=00:02:04:06:08:04,host_ifname=veth113.1,host_mac=00:19:99:c4:66:87"

i restarted the network

Code:
root@smallhosting:~# /etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).
Reconfiguring network interfaces...Removed VLAN -:eth1.113:-

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 113 to IF -:eth1:-
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 124 to IF -:eth1:-
done.

this is the ifconfig

Code:
root@smallhosting:~# ifconfig
br0       Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.180  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2325 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:184371 (180.0 KiB)  TX bytes:5912 (5.7 KiB)

eth1      Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:121742 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4798 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11519797 (10.9 MiB)  TX bytes:518455 (506.3 KiB)
          Interrupt:18 Memory:fe600000-fe620000

eth1.113  Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.113  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:468 (468.0 B)

eth1.124  Link encap:Ethernet  HWaddr 00:19:99:c4:66:87
          inet addr:89.42.231.124  Bcast:89.42.231.255  Mask:255.255.255.0
          inet6 addr: fe80::219:99ff:fec4:6687/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:468 (468.0 B)

i started the container

Code:
root@smallhosting:~# vzctl start 113
Restarting container
Starting container ...
Container is mounted
Setting CPU units: 1000
Set hostname: test.smallhosting.ro
File resolv.conf was modified
Configure veth devices: veth113.0 veth113.1
ifname=
host_ifname=
Initializing interface veth113.0 for VE113.
Adding interface veth113.0 to the bridge br0.
Adding an IP 89.42.231.113/24 to the eth1.113 for VE113.
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
ifname=
host_ifname=
Initializing interface veth113.1 for VE113.
SIOCSIFADDR: No such device
veth113.1: ERROR while getting interface flags: No such device
Adding interface veth113.1 to the bridge br0.
interface veth113.1 does not exist!
Cannot find device "eth1.124"
Adding an IP 89.42.231.124/24 to the eth1.124 for VE113.
Cannot find device "eth1.124"
Adding a route from VE0 to VE113.
ifname=
host_ifname=
Initializing interface veth113.0 for VE113.
Adding interface veth113.0 to the bridge br0.
device veth113.0 is already a member of a bridge; can't enslave it to bridge br0.
Adding an IP 89.42.231.113/24 to the eth1.113 for VE113.
RTNETLINK answers: File exists
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
ifname=
host_ifname=
Initializing interface veth113.1 for VE113.
Adding interface veth113.1 to the bridge br0.
Adding an IP 89.42.231.124/24 to the eth1.124 for VE113.
Adding a route from VE0 to VE113.
RTNETLINK answers: File exists
Container start in progress...

i entered in container "vzctl enter 113"


ifconfig in container
Code:
eth1.113  Link encap:Ethernet  HWaddr 00:02:04:06:08:02
          inet addr:89.42.231.113  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::202:4ff:fe06:802/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1393 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:103134 (100.7 KiB)  TX bytes:600 (600.0 B)

eth1.124  Link encap:Ethernet  HWaddr 00:02:04:06:08:04
          inet addr:89.42.231.124  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::202:4ff:fe06:804/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1386 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:102147 (99.7 KiB)  TX bytes:600 (600.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

route -n on container

Code:
root@test:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
89.42.231.1     0.0.0.0         255.255.255.255 UH    0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.124
0.0.0.0         89.42.231.1     0.0.0.0         UG    0      0        0 eth1.113

no internet access
no pings in gateway
Code:
root@test:/# ping 89.42.231.1
PING 89.42.231.1 (89.42.231.1) 56(84) bytes of data.

--- 89.42.231.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

root@test:/# ping 89.42.231.1
PING 89.42.231.1 (89.42.231.1) 56(84) bytes of data.

--- 89.42.231.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms

route -n on server

Code:
89.42.231.124   0.0.0.0         255.255.255.255 UH    0      0        0 br0
89.42.231.113   0.0.0.0         255.255.255.255 UH    0      0        0 br0
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.113
89.42.231.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1.124
0.0.0.0         89.42.231.1     0.0.0.0         UG    0      0        0 br0

ping from server in container at 89.42.231.113
Code:
root@smallhosting:~# ping 89.42.231.113
PING 89.42.231.113 (89.42.231.113) 56(84) bytes of data.
64 bytes from 89.42.231.113: icmp_req=1 ttl=64 time=0.020 ms
64 bytes from 89.42.231.113: icmp_req=2 ttl=64 time=0.033 ms
64 bytes from 89.42.231.113: icmp_req=3 ttl=64 time=0.028 ms
^C
--- 89.42.231.113 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.020/0.027/0.033/0.005 ms

ping in same container but in 89.42.231.124
Code:
root@smallhosting:~# ping 89.42.231.124
PING 89.42.231.124 (89.42.231.124) 56(84) bytes of data.
64 bytes from 89.42.231.124: icmp_req=1 ttl=64 time=0.020 ms
64 bytes from 89.42.231.124: icmp_req=2 ttl=64 time=0.025 ms
64 bytes from 89.42.231.124: icmp_req=3 ttl=64 time=0.024 ms
^C
--- 89.42.231.124 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.020/0.023/0.025/0.002 ms

and i tryed a lots of tutorials and how to make but nothig

someone can help me plz? i need quick of this

thx and sorry for my english