Network devices in kvm containers

safranero

Renowned Member
Jan 21, 2010
39
0
71
Spain
Hello,

I want to migrate OpenVZ containers to kvm containers. In that vps I have configurate more than 1 ip.

I saw I can configure manually aliases of an interface eth0 for configure more than 1 ip. eth0:1, eth0:2, etc. But this configuration is manual and I want to use cloud-init. For cloud-init working this one needs a network device for each ip. In a example, I created kvm container with two network devices with same options, and SO Centos 7. I configured correctly cloud-init network but when I start the container though interfaces are up only works first ip. If I down eth0 and up eth1 the secondary ip works and viceversa.

Can you help me to discover the problem?

The two ips are in same network and your gateway is the same.

Configuration files:
Code:
[root@test network-scripts]# cat ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
GATEWAY=31.200.240.161
HWADDR=d6:0a:7f:95:90:16
IPADDR=31.200.240.134
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
[root@test network-scripts]# cat ifcfg-eth1
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth1
GATEWAY=31.200.240.161
HWADDR=3a:ef:bf:f9:88:d9
IPADDR=31.200.240.145
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
[root@test network-scripts]#

Result of command "ip a":

Code:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d6:0a:7f:95:90:16 brd ff:ff:ff:ff:ff:ff
    inet 31.200.240.134/24 brd 31.200.240.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::d40a:7fff:fe95:9016/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 3a:ef:bf:f9:88:d9 brd ff:ff:ff:ff:ff:ff
    inet 31.200.240.145/24 brd 31.200.240.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::38ef:bfff:fef9:88d9/64 scope link
       valid_lft forever preferred_lft forever

Result of command "ip route":
Code:
default via 31.200.240.161 dev eth1
31.200.240.0/24 dev eth1 proto kernel scope link src 31.200.240.145
31.200.240.0/24 dev eth0 proto kernel scope link src 31.200.240.134

Thanks to all
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!