Adding a second IP to a LXC Container

@PretoX

Sorry I did not answer you before. I've been testing all weekend ... I could not get it to work ... I tried other virtualization software and it did not work either.
But then, I read in the documentation of that other software, that to make KVM work with more than 1 ip in Soyoustart and OVH had to ...

1. In the OVH / Soyoustart Manager, the failover ips that we want to add to the VPS must be given the same MAC that has the main IP of the VPS.

That is when we create a VPS we assign an IP with your MAC ... ok
But if we want to add more ips to that vps, these ips have to be created the same mac as the ip of the vps.
This is done from the OVH / Soyoustart panel.

Now the VPS if it responds to the ping of all the ips added !!

What a headache!!!!
 
you forgot something obvious:

chmod +x /sbin/ifup-local
reboot or
cd /etc/sysconfig/network-scripts && ./ifup-post ifcfg-eth0

also check all other interfaced added from proxmox are removed

I execute this command and I have this result.
Any solution?
SO: Centos 7

Code:
[root@ip network-scripts]# ./ifup-post ifcfg-eth0
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
 
.... Only former imported containers from openvz doesn't work.

If the CT imported from OpenVZ then you must set the network configuration manually to make LXC works.

You must:
  1. Add MAC Address which OpenVZ doesn't require it
  2. CIDR for IP. In OpenVZ you write 192.168.1.1 but LXC must be 192.168.1.1/24 for example
  3. Add Gateway which OpenVZ doesn't require it
 
If the CT imported from OpenVZ then you must set the network configuration manually to make LXC works.

You must:
  1. Add MAC Address which OpenVZ doesn't require it
  2. CIDR for IP. In OpenVZ you write 192.168.1.1 but LXC must be 192.168.1.1/24 for example
  3. Add Gateway which OpenVZ doesn't require it
And in CT LXC?
IP does not ping externally.

Thanks
 
@PretoX

Sorry I did not answer you before. I've been testing all weekend ... I could not get it to work ... I tried other virtualization software and it did not work either.
But then, I read in the documentation of that other software, that to make KVM work with more than 1 ip in Soyoustart and OVH had to ...

1. In the OVH / Soyoustart Manager, the failover ips that we want to add to the VPS must be given the same MAC that has the main IP of the VPS.

That is when we create a VPS we assign an IP with your MAC ... ok
But if we want to add more ips to that vps, these ips have to be created the same mac as the ip of the vps.
This is done from the OVH / Soyoustart panel.

Now the VPS if it responds to the ping of all the ips added !!

What a headache!!!!

HOLY JESUS THANK YOU SIR! I spent SOOOO much time trying to figure out why the main IP would work just fine, but any additional IPs I tried to add afterwards would all fail when attempting to access from (internet -> VM) ... I went back into OVH manager and configured the virtual MAC for the additional IP on the VM to the same mac as the main IP ... and voila! It started working! My god I can't tell you how much time I spent trying to figure this out!!

THANK YOU!!
 
For Centos I use this:

vim /sbin/ifup-local
#!/bin/sh
if [[ "$1" == "eth0" ]]
then
ip a add xxx.xxx.xxx.128/24 dev eth0:128
ip a add xxx.xxx.xxx.131/24 dev eth0:131
ip a add xxx.xxx.xxx.132/24 dev eth0:132
ip a add xxx.xxx.xxx.133/24 dev eth0:133
ip a add xxx.xxx.xxx.134/24 dev eth0:134
#else
#DO_NOTHING
fi

and in /etc/sysconfig/network-scripts/ifup-aliases

if [ -x /sbin/ifup-local ]; then
for DEVICE in $ifuplocal_queue ; do
/sbin/ifup-local ${DEVICE}
done
fi

Just to mention that this works perfectly with failover IP @ online.net as well. THANKS
You just need to make sure that the same MAC address is being used for any failover IP that should be used by the container, and that the MAC address of eth0 on the container is also set to the same MAC address.
 
Hello. I use OVH and failover ip's

In debian 9.3 container multiple ip's work great, but in ubuntu 16.04 and 17.10 container multiple ip's does not work

proxmox-ve: 5.1-42 (running kernel: 4.13.13-5-pve)
pve-manager: 5.1-46 (running version: 5.1-46/ae8241d4)
pve-kernel-4.13: 5.1-43
pve-kernel-4.13.16-1-pve: 4.13.16-43
pve-kernel-4.13.13-5-pve: 4.13.13-38
pve-kernel-4.13.13-4-pve: 4.13.13-35
pve-kernel-4.10.17-1-pve: 4.10.17-18
corosync: 2.4.2-pve3
criu: 2.11.1-1~bpo90
glusterfs-client: 3.8.8-1
ksm-control-daemon: 1.2-2
libjs-extjs: 6.0.1-2
libpve-access-control: 5.0-8
libpve-common-perl: 5.0-28
libpve-guest-common-perl: 2.0-14
libpve-http-server-perl: 2.0-8
libpve-storage-perl: 5.0-17
libqb0: 1.0.1-1
lvm2: 2.02.168-pve6
lxc-pve: 2.1.1-3
lxcfs: 2.0.8-2
novnc-pve: 0.6-4
proxmox-widget-toolkit: 1.0-11
pve-cluster: 5.0-20
pve-container: 2.0-19
pve-docs: 5.1-16
pve-firewall: 3.0-5
pve-firmware: 2.0-4
pve-ha-manager: 2.0-5
pve-i18n: 1.0-4
pve-libspice-server1: 0.12.8-3
pve-qemu-kvm: 2.9.1-9
pve-xtermjs: 1.0-2
qemu-server: 5.0-22
smartmontools: 6.5+svn4324-1
spiceterm: 3.0-5
vncterm: 1.5-3
zfsutils-linux: 0.7.6-pve1~bpo9


arch: amd64
cores: 4
hostname: ubuntu1710
memory: 1024
net0: name=eth0,bridge=vmbr0,gw=gw_ip,hwaddr=mac,ip=ip/32,type=veth
net1: name=eth01,bridge=vmbr0,gw=gw_ip,hwaddr=mac,ip=ip/32,type=veth
ostype: ubuntu
rootfs: local:103/vm-103-disk-1.raw,size=8G
swap: 512


arch: amd64
cores: 4
hostname: debian
memory: 1024
net0: name=eth0,bridge=vmbr0,gw=gw_ip,hwaddr=mac,ip=ip/32,type=veth
net1: name=eth01,bridge=vmbr0,gw=gw_ip,hwaddr=mac,ip=ip/32,type=veth
ostype: debian
rootfs: local:102/vm-102-disk-1.raw,size=8G
swap: 512

Any ideas?
 
  • Like
Reactions: atom70
I'm also using the latest version of ProxMox.

When I create a container inside proxmox with multiple interfaces with public IP address and their mac (OVH) only the first interface works.

This problem only happens with Centos7 and Ubuntu, Debian works perfectly. (My templates are up to date)

I look at the network configurations for each container created with the templates and everything is the same, it's really weird that only Debian works ...

Gabriel
 
Same prob to me...have to change my haproxy with multiple IP´s back to Debian since Ubuntu 18.04.2 LXC does not work with different gateways.
 
1000 thanks to @PretoX
the failover ips that we want to add to the VPS must be given the same MAC that has the main IP of the VPS.

I was adding post-up rules on /etc/network/interfaces on the host and it works too, but it's too manual, error prone and requires changes when moving the lxc to another host... this is much cleaner and can be done in the gui
 

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!