Adding a second IP to a LXC Container

Ok, i did a few tests over the weekend. It looks lilke my pve Installation is working correct.
A fresh installed debian is working with more than one ip adresses - and bridging also.

Only former imported containers from openvz doesn't work. And here Ubuntu 12.04 and 14.04.
I got my prior images from https://openvz.org/Download/template/precreated

Can anybody say what is necessary in these images that they'll work correct in lxc?
 
Same stuff after updating proxmox today Live containers lost routes after proxmox rebooted. But with centos 7 container, can't assign the same gateway for all nics.... help!
 
Updating my previous post
my configs are:
proxmox-ve: 4.2-54 (running kernel: 4.4.10-1-pve)
pve-manager: 4.2-15 (running version: 4.2-15/6669ad2c)
pve-kernel-4.4.6-1-pve: 4.4.6-48
pve-kernel-4.2.6-1-pve: 4.2.6-36
pve-kernel-4.2.8-1-pve: 4.2.8-41
pve-kernel-4.4.10-1-pve: 4.4.10-54
lvm2: 2.02.116-pve2
corosync-pve: 2.3.5-2
libqb0: 1.0-1
pve-cluster: 4.0-42
qemu-server: 4.0-81
pve-firmware: 1.1-8
libpve-common-perl: 4.0-68
libpve-access-control: 4.0-16
libpve-storage-perl: 4.0-55
pve-libspice-server1: 0.12.5-2
vncterm: 1.2-1
pve-qemu-kvm: 2.5-19
pve-container: 1.0-68
pve-firewall: 2.0-29
pve-ha-manager: 1.0-32
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u2
lxc-pve: 1.1.5-7
lxcfs: 2.0.0-pve2
cgmanager: 0.39-pve1
criu: 1.6.0-1
zfsutils: 0.6.5-pve9~jessie
Broken container config:
arch: amd64
cpulimit: 6
cpuunits: 1024
hostname: ps3
memory: 20480
mp0: VM-DATA:subvol-105-disk-2,acl=0,mp=/DATA,size=250G
nameserver: 8.8.8.8 8.8.4.4
net0: bridge=vmbr0,gw=210.56.153.253,hwaddr=36:63:36:63:37:61,ip=ip.ip.ip.ip1/24,name=eth0,type=veth
net1: bridge=vmbr0,hwaddr=36:38:32:66:64:35,ip=localnetip/24,name=eth1,type=veth
net2: name=eth5,bridge=vmbr0,hwaddr=66:62:61:65:66:39,ip=ip.ip.ip.ip2/24,type=veth
net3: name=eth3,bridge=vmbr0,hwaddr=36:37:35:35:65:63,ip=ip.ip.ip.ip3/24,type=veth
onboot: 1
ostype: centos
protection: 1
rootfs: VM-DATA:subvol-105-disk-1,acl=0,size=100G

snaptime: 1467632550
swap: 10240

running new lxc from the same template runs both nic's well, so only old containers are brocken. plz help
 
Last edited:
Yes that works for me and i have an ovh server too

I have a OVH server too and that didn't work for me neither. I rebooted my host a few weeks ago because of a new kernel (so my system is up to date) and since then the second IP has become unreachable. Everything is correctly configured (in fact, the configuration hasn't changed since the time the second IP was reachable), I see the two interfaces in the container, I can ping them from there but from the outside the second IP is invisible.

I have contacted OVH and they say that the container's IP is correctly routed to the host's IP from their point of view (via virtual MAC address).
 
@Philipp Page @ianux @PretoX

Forgive, did you find a solution? I have the same problem, also in OVH.


From the container if I ping the added ips, respond. But from the internet there is no ping. So I can not give ips dedicated to webs from cpanel.
 
@Philipp Page @ianux @PretoX

Forgive, did you find a solution? I have the same problem, also in OVH.


From the container if I ping the added ips, respond. But from the internet there is no ping. So I can not give ips dedicated to webs from cpanel.
Yes, there is a solution, do not add another network interfaces - add aliases. So you have 2 nic's present in the container(example): one for internal network 2. external ip1 (eth1) ext ip2 (eth1:1) etc and it will work and cpanel or plesk will see it
 
@PretoX
Please, could you explain how? Please!! Please!
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
 
  • Like
Reactions: albans
@PretoX I'm going crazy, this is incredible. I can not make it work.

- I have a dedicated OVH server installed with its proxmox 4.3 image. okay
- Next I create a container with Centos 7 minimal. A This container assigned an IP failover, which will be the main IP of the container, and which CPANEL uses as IP share. OK, I installed CPANEL and created a domain account. Everything works perfectly.

Now to that same container I want to add another IP Failover, to be used by CPANEL as IP Dedicated by another domain.

- As the container is centos ... I go to the route that you indicate me. / Sbin / and there does not exist, the ifup-local file is not there. Then I created the file with vim / sbim / ifup-local.

And add

#!/bin/sh
if [[ "$1" == "eth0" ]]
then
ip a add IP_FAILOVER_NEW/24 dev eth0:1
#else
#DO_NOTHING
fi

Sabe changes and create file, with escape, :wq
Correct?

Now... Go to file... /etc/sysconfig/network-scripts/ifup-aliases

This file exists, ok.
When I edit it, I go down to the bottom of the file and I can see that the lines that you indicate to me, exist there.

I close the file and turn it off and light the container.

I then enter ssh into the container and check that the ping from inside the container to the new IP failover is successful. But from outside (internet) does not respond.

I'm going to CPANEL, and I add a new ip.
Add new ip ... IP FAILOVER NETMASK 255.255.255.255

Then I create a domain, and assign that ip to the domain.

Well it does not work, it still does not respond to ping, ip failover or domain obviously.

This is insane, and it can not be so complicated.
 
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
 
@PretoX

206l7wj.png



/sbin/ifup-local

1vmfl.png


33auzw3.png


I do not know if I have to do anything else in some other file, in the interfaces file ... or in the console of proxmox ... I do not know what to do.

I hope to see you tell me before formatting.
 

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!