Adding a second IP to a LXC Container

Discussion in 'Proxmox VE: Networking and Firewall' started by Philipp Page, Apr 26, 2016.

  1. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Hello,

    I am new with Proxmox and wanted to add a second static IP address to my LXC Container.
    It is currently configured with the IP 178.33.157.22 and works great (bridged mode).
    Now I was trying to add 178.33.157.21 and entered instead of net0 net1 and instead of eth0 eth1. But it does not work, the IP does not even show up in Proxmox:
    [​IMG]
    [​IMG]

    I hope that someone can help.
    Edit: No error or message shows up while adding.
     
  2. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,103
    Likes Received:
    473
    works fine here..

    could you post the output of "pveversion -v" and the content of "/etc/pve/lxc/ID.conf" (where ID is your container's ID)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Here the output of "pveversion -v":
    Code:
    proxmox-ve: 4.1-41 (running kernel: 4.2.8-1-pve)
    pve-manager: 4.2-2 (running version: 4.2-2/725d76f0)
    pve-kernel-4.2.8-1-pve: 4.2.8-41
    lvm2: 2.02.116-pve2
    corosync-pve: 2.3.5-2
    libqb0: 1.0-1
    pve-cluster: 4.0-39
    qemu-server: 4.0-72
    pve-firmware: 1.1-8
    libpve-common-perl: 4.0-59
    libpve-access-control: 4.0-16
    libpve-storage-perl: 4.0-50
    pve-libspice-server1: 0.12.5-2
    vncterm: 1.2-1
    pve-qemu-kvm: 2.5-14
    pve-container: 1.0-62
    pve-firewall: 2.0-25
    pve-ha-manager: 1.0-28
    ksm-control-daemon: 1.2-1
    glusterfs-client: 3.5.2-2+deb8u1
    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

    And here the config file output with the wrong configured IP on net1:
    Code:
    arch: amd64
    cpulimit: 2
    cpuunits: 2048
    hostname: gameserver.cod4-server.info
    memory: 6144
    net0: bridge=vmbr0,gw=149.202.210.254,hwaddr=02:00:00:51:cd:b1,ip=178.33.157.22/32,name=eth0,type=veth
    net1: bridge=vmbr0,hwaddr=02:00:00:e7:89:c2,name=eth1,type=veth
    ostype: debian
    rootfs: local:1001/vm-1001-disk-1.raw,size=250G
    swap: 6144

    After some tests I also noticed that the ip assignment works if the container is stopped but not if it is running.
     
  4. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,103
    Likes Received:
    473
    this looks like the "hotplugging" of new network configuration fails in the container, in which case the old configuration is restored.
    you should be able to see any error messages when updating the configuration with "pct set", for example with
    "pct set ID -net1 bridge=vmbr0,hwaddr=02:00:00:e7:89:c2,name=eth1,type=veth,ip=XX.XXX.XX.XX,gw=XX.XX.XX.XX"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    I actually dont know what it was, but after doing apt-get dist-upgrade it works, thanks anyways for your support.
     
  6. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    After having a more detailed look at the problem, I recognised that it is not fixed.

    Here the error message:
    Code:
    root@srv02:~# pct set 1001 -net1 bridge=vmbr0,hwaddr=02:00:00:51:cd:b1,name=eth1,type=veth,ip=178.33.157.22/32,gw=149.202.210.254
    RTNETLINK answers: File exists
    command 'lxc-attach -n 1001 -s NETWORK -- /sbin/ip -4 route add 149.202.210.254 dev eth1' failed: exit code 2
    
    When I do not add the gateway to the command, the IP can be added but does not work since the gateway is not set.
     
    #6 Philipp Page, May 17, 2016
    Last edited: May 18, 2016
  7. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,103
    Likes Received:
    473
    Could you post the contents of "/etc/network/interfaces" and the output of "ip route" (both in the container)? You cannot add the same gateway/route twice, which is why the command fails.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Here the Output of /etc/network/interfaces when i do not enter the gateway:
    Code:
    root@gameserver:~# cat /etc/network/interfaces
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 178.33.157.21
            netmask 255.255.255.255
            post-up ip route add 149.202.210.254 dev eth0
            post-up ip route add default via 149.202.210.254 dev eth0
            pre-down ip route del default via 149.202.210.254 dev eth0
            pre-down ip route del 149.202.210.254 dev eth0
    
    auto eth1
    iface eth1 inet static
            address 178.33.157.22
            netmask 255.255.255.255
    

    And here ip route
    Code:
    root@gameserver:~# ip route
    default via 149.202.210.254 dev eth0
    149.202.210.254 dev eth0  scope link
    

    You are right, when I have the gateway added on one network adapter it works. So now it is configured that it works :eek:
     
  9. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,103
    Likes Received:
    473
    yes, this is a limitation of the kernel - one gateway can only be used once per routing table.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
  11. chris121212

    chris121212 New Member

    Joined:
    May 26, 2016
    Messages:
    24
    Likes Received:
    0
    What exactly does that mean? On OVH Servers there are a plenty of Failover Ip addresses and every address has the same gateway.
    Is there a solution?
     
  12. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Yes, there is a simple solution. Do it like Fabian said: Only add the gateway once for net0 and let the field empty for the following network adapters and only fill out the ip address field. It should look like that:
    [​IMG]
     
  13. chris121212

    chris121212 New Member

    Joined:
    May 26, 2016
    Messages:
    24
    Likes Received:
    0
    hmm, does this really work for you?
    When i add the gateway to net1 this ip is pinging - and when i add the gateway to net0 this ip. But in no case both.
     
  14. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Yes that works for me and i have an ovh server too
     
  15. chris121212

    chris121212 New Member

    Joined:
    May 26, 2016
    Messages:
    24
    Likes Received:
    0
    Still not working :-/ even with fresh installed container. I've got the exactly same settings like you - of course other ip addresses.
    Any ideas?
     
  16. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    Do you have the latest proxmox version installed?
     
  17. chris121212

    chris121212 New Member

    Joined:
    May 26, 2016
    Messages:
    24
    Likes Received:
    0
    yes:

    ii lxc-pve 1.1.5-7 amd64 Linux containers usersapce tools
    ii lxcfs 2.0.0-pve2 amd64 LXC userspace filesystem
    ii novnc-pve 0.5-6 amd64 HTML5 VNC client
    ii pve-cluster 4.0-39 amd64 Cluster Infrastructure for Proxmox Virtual Environment
    ii pve-container 1.0-64 all Proxmox VE Container management tool
    ii pve-firewall 2.0-27 amd64 Proxmox VE Firewall
    ii pve-firmware 1.1-8 all Binary firmware code for the pve-kernel
    ii pve-ha-manager 1.0-31 amd64 Proxmox VE HA Manager
    rc pve-kernel-4.2.6-1-pve 4.2.6-36 amd64 The Proxmox PVE Kernel Image
    ii pve-kernel-4.2.8-1-pve 4.2.8-41 amd64 The Proxmox PVE Kernel Image
    ii pve-kernel-4.4.8-1-pve 4.4.8-51 amd64 The Proxmox PVE Kernel Image
    ii pve-libspice-server1 0.12.5-2 amd64 SPICE remote display system server library
    ii pve-manager 4.2-5 amd64 The Proxmox Virtual Environment
    ii pve-qemu-kvm 2.5-17 amd64 Full virtualization on x86 hardware

    I'm using the Image from OVH, which is working perfect besides the more than one ip problem. What version do u have?
     
  18. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    I am using the same version. Can you share your hosts network configuration. Then i can compare it with my configuration, probably we can find an error there.
     
  19. chris121212

    chris121212 New Member

    Joined:
    May 26, 2016
    Messages:
    24
    Likes Received:
    0
    from Server or Containers?
     
  20. Philipp Page

    Philipp Page New Member

    Joined:
    Apr 26, 2016
    Messages:
    28
    Likes Received:
    0
    From the node /etc/network/interfaces
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice