Proxmox 4 – Get IP of LXC container

The description below is true for Ubuntu containers, but might be valid for other Linux distros.

If you’re using Proxmox and creating LXC-containers, you might run into the problem of figuring out what IP addresses are assigned to the different containers (if you are using DHCP in the containers).

Proxmox Ubuntu Linux IP address

Proxmox Ubuntu Linux IP address

I use a lot of containers for various tasks, and they are only turned on when I need them, so giving them static IP addresses doesn’t make sense in my case.

Since Proxmox does not know the IP address of a container, it is not shown in the dashboard.

The way I do it is to modify the startup script so that the IP-address of the container is shown when you enter the console of a container from the Proxmox UI.

What you want to do is have the container display the IP address as soon as the console is displayed, so that you don’t need to login to the container.

The text displayed when starting a console is contained in a file called /etc/issue inside the container.

In order to make this file contain the IP address, a few lines need to be added to the containers /etc/rc.local file:

root@mycontainer:~# nano /etc/rc.local

Change the content of this file below the comments so that it looks like this:

lsb_release -d -s >/etc/issue
printf "\nIP-address: %s\n\n" `hostname -I` >>/etc/issue
exit 0

Note the “backticks” around the hostname command.

This changes the content of the /etc/issue file whenever the container is booted, and so will always display the correct IP address, and all you need to do to get the IP is to start the console.