Link to home
Start Free TrialLog in
Avatar of Goutham
GouthamFlag for India

asked on

lxd containers not getting ip released from the host and also manually configured ip for container not working

containers not getting ip.txtDear Experts

The newly created lxd containers are not getting IP released from the host and also the manually configured IP in the network config of the containers are  not working ( though assigned not getting listed when execute lxc list)

routing table of the host machine : is added with 51.195.168.16/28  (with this 16 IP’s which means 16 containers with 16 IP’s )

 Able to successfully create 04 containers but new container created assigned IP but this is not getting assigned, attached few network commands executed this might be helpful for investigation

lxc list
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|  NAME   |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i1focal | RUNNING | 51.195.168.16 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fedd:4746 (eth1) | CONTAINER | 0         |
|         |         | 10.192.120.198 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe8e:f50 (eth0)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i2focal | RUNNING | 51.195.168.19 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe7d:2be8 (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.117 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe54:4aa (eth1)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i6      | RUNNING |                       | fd42:f3e3:9bff:fc2f:216:3eff:fec1:2768 (eth0) | CONTAINER | 0         |
|         |         |                       | fd42:f3e3:9bff:fc2f:216:3eff:fe38:2c5d (eth1) |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| u1      | RUNNING | 51.195.168.17 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe85:725e (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.122 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe7f:2b28 (eth1) |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| u5      | RUNNING | 51.195.168.20 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fee9:f988 (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.16 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe19:7ec (eth1)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

the above i6 contanier is not getting ip released
----------
vi /var/snap/lxd/common/lxd/storage-pools/default/containers/i6/rootfs/etc/netplan/60-public-init.yaml
network:
       version: 2
              ethernets:
                                eth0:
                                                  addresses:
                                                                    - 51.195.168.18/32

attached few network commands, please help to fix this issue, thank you.




Avatar of Goutham
Goutham
Flag of India image

ASKER

In contd to above, tried to now to create another container named i7 and started ( this time did not manually configure/assign the IP for this container in the following file /var/snap/lxd/common/lxd/storage-pools/default/containers/i7/rootfs/etc/netplan/60-public-init.yaml ( so when manually following file is 60-public-init.yaml is not created with the network config content in it,  now the host machine has automatically assigned the IP 10.192.120.165  but when I assign the IP then start and stop the container both IP's does not appear in the list, below output after the manual IP configured and restarted the container - I would like to tell is if IP config is not done by creating the file 60-public-init.yaml  in the var/snap/lxd/common/lxd/storage-pools/default/containers/i7/rootfs/etc/netplan/ and start the container host releases the IP but as per my requirement when file 60-public-init.yaml  is created with IP details content and restart the container this even takes out the host assigned IP also finally no IP's are listed.

lxc list
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|  NAME   |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i1focal | RUNNING | 51.195.168.16 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fedd:4746 (eth1) | CONTAINER | 0         |
|         |         | 10.192.120.198 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe8e:f50 (eth0)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i2focal | RUNNING | 51.195.168.19 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe7d:2be8 (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.117 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe54:4aa (eth1)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i6      | RUNNING |                       | fd42:f3e3:9bff:fc2f:216:3eff:fec1:2768 (eth0) | CONTAINER | 0         |
|         |         |                       | fd42:f3e3:9bff:fc2f:216:3eff:fe38:2c5d (eth1) |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| i7      | RUNNING | 10.192.120.165 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe87:991a (eth0) | CONTAINER | 0         |
|         |         |                       | fd42:f3e3:9bff:fc2f:216:3eff:fe5e:e20b (eth1) |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| u1      | RUNNING | 51.195.168.17 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe85:725e (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.122 (eth0) | fd42:f3e3:9bff:fc2f:216:3eff:fe7f:2b28 (eth1) |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| u5      | RUNNING | 51.195.168.20 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fee9:f988 (eth0) | CONTAINER | 0         |
|         |         | 10.192.120.16 (eth0)  | fd42:f3e3:9bff:fc2f:216:3eff:fe19:7ec (eth1)  |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+




Avatar of David Favor
Unable to understand you exact commands.

The correct sequence is...

1) Create a container (in stopped state).

2) Edit your netplan file.

3) Start container.

4) You should see your 10.X.X.X lxcbr0 IP + your IPV4 IP.

Note: You're doing something with eth1 again, which will fail unless you rewrite LXD.

Remove all eth1 references.

For IPV6 assistance, best to open a question on https://discuss.linuxcontainers.org as I avoid IPV6 like the plague, so likely developers will be best to ask about IPV6.

Tip: Get IPV4 with eth0 only working, then branch out to getting IPV6 to work, then (shudder) rewriting LXD to work with eth1.

Note: There might be eth1 support now. This is also a question to ask developers.
Avatar of Goutham

ASKER

thanks sir, I am not considering eth1 and no where eth1 is manually configured( to test it configured and immediately removed and now everything is on eth0 only)

I am following the sequence as per your inputs, the created new container gets assigned with IP automatically from the host machine but keeping in the stop state edit the netplan file and assign the IP manually and then start the container, now even the earlier  automatically assigned IP of 10.x.. to the container by host machine also goes off/stops working, therefore both the IP's are found not working ( host machine automatically assigned to the container + manual assigned IP by editing netplan file both does not work/ able to see when performed lxc list in the ip section entry is blank.). 


Avatar of Goutham

ASKER

Hi sir,
deleted those container of those of ip config were not coming up and created newly but this time copied the working netplan 60-public-init.yaml  to this container /etc/netplan and modified the ip addressupdated_lxc_list.txt and started the container, now it is working as expected.
 In same way created multiple containers, and now all are working as expected, but afraid thinking on would have gone wrong and what if the same same issue come back later, attached updated lxc list.
Also after deleting the container of non working restarted the system, it was found none of the containers were accessible from external then manually executed the following
ip -4 route add 144.217.145.112/28
after this started working as expected, think when host machine is restarted routing table gets lost, not sure can you please help me with script here so that each time when host machine restarted routing table gets added with the routes of my ip block.




 
SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Goutham

ASKER

Sir, Thank you very much for the inputs, may I request you to help me on how to setup script (and should I have to put it in cron) can you please help me on the for the following to run  ip -4 route add 51.195.168.16/28 dev lxdbr0, will be great help sir.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial