Why can't you add a second IP to the same nic in LXC?

robetus

Well-Known Member
Jul 8, 2017
54
1
48
Las Vegas, NV
Is there a reason why the proxmox developers opted to not be able to add a second or even third IP to the nics of an LXC container, even though it's totally possible to do this? I shouldn't have to add multiple nics to get multiple IPs to an LXC container. I also tried to add multiple IPs to eth0 manually which worked fine until you have to reboot and proxmox reconfigures the networking.

I can't think of any reason why you shouldn't be able to add multiple IPv4 and IPv6 addresses to an LXC container in the GUI of proxmox to the same nic card.

I also tried two nics for two IPs but the network just totally stops responding and becomes unstable. Switching to KVM now.
 
Already tried that, and like I said proxmox resets everything after a reboot. Is there a way to disable proxmox from resetting the entire network on the container? There should be at least this option in proxmox.

If you must manage the network through the GUI in proxmox then you must be able to add multiple IPs to the same nic in the GUI. To me it's very simple.

Add a plus sign next to the IP addresses both IPv4 and IPv6 and let people add away!
 
That's fine, thanks for the info but I still don't think there is any reason at all that proxmox should not have multiple IP address additions in the GUI. Proxmox already has the nic mappings setup, it wouldn't be hard to map an additional IP from the GUI to IPADDR1, IPADDR2, etc.
 
it wouldn't be hard to map an additional IP from the GUI to IPADDR1, IPADDR2, etc.

Container network setup can be much more complex that that, and we do not want to configure all those things on the hypervisor side.
 
Understood you can do a lot with the network setup, but I would say that multiple IPs for one container on one nic is common enough to have it in the GUI. Or, a checkbox in the GUI network config for a self-managed network.
 
We also face same issue.

On reboot all LXC loses all extra IPs.

what is exact procedure to add second IP?

I am adding eth1 with new IP, but on reboot it is gone.

Exaclty, hopefully others will respond the same way so they'll add it to the GUI. This a very normal thing to need. All the other complicated networking is for maybe 1% of users.

You need to add an ignore file for the interface file so proxmox won't override it. At least that's what I understand. So for CentOS you would add something like: /etc/.pve-ignore.ifcfg.eth0 into your host. The file can just be empty and created with a touch command.
 
LXC extra IP with different subnet adding steps.

If LXC has different subnet than extra IP........

First add interface eth0 via GUI in the Node for the guest

Then login to guest and create extra config file for each IP.

1] login to proxmox select CT XXX > Network > add one NIC with XXX.XXX.XXX.XXX/32 and gateway XXX.XXX.XXX.1

2.login to CT and navigate to cd /etc/sysconfig/network-scripts

3. Run ls and you can list the network config files and will see :-

ifcfg-eth0

4. Now we can add extra ip by creating a new file : vi ifcfg-eth0:0

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.10.10.10
NETMASK=255.255.255.255
GATEWAY=10.10.10.1

and save it

5. like this create one file each with ip and gateway of the each extra ip and save it (vi ifcfg-eth0:1 vi ifcfg-eth0:2 vi ifcfg-eth0:3 vi ifcfg-eth0:4 so 0n.......)


6. Then run service network restart.

May take upto 1 -2 minutes to get it ping. so please wait.
 
Thanks @Vasu Sreekumar that's probably the best way to do it, but I still think this should be in the GUI, not gonna change my mind about that because you actually can add multiple IPs to the same interface with linux.
 
LXC extra IP with different subnet adding steps.

If LXC has different subnet than extra IP........

First add interface eth0 via GUI in the Node for the guest

Then login to guest and create extra config file for each IP.

1] login to proxmox select CT XXX > Network > add one NIC with XXX.XXX.XXX.XXX/32 and gateway XXX.XXX.XXX.1

2.login to CT and navigate to cd /etc/sysconfig/network-scripts

3. Run ls and you can list the network config files and will see :-

ifcfg-eth0

4. Now we can add extra ip by creating a new file : vi ifcfg-eth0:0

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.10.10.10
NETMASK=255.255.255.255
GATEWAY=10.10.10.1

and save it

5. like this create one file each with ip and gateway of the each extra ip and save it (vi ifcfg-eth0:1 vi ifcfg-eth0:2 vi ifcfg-eth0:3 vi ifcfg-eth0:4 so 0n.......)


6. Then run service network restart.

May take upto 1 -2 minutes to get it ping. so please wait.

Not working for me proxmox 5.2 any other solutions ?
 

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!