Static IP for CentOS LXC container

LXC containers get dynamic IP from DHCP. When you stop and start a container, its IP gets changed. If you hosting some web application on this container, you need to point the application to new IP. To avoid this, you can configure static IP on the container.

LXC containers get IP in the range 10.0.3.2-255. To make CentOS container IP static, edit file

Find

Replace with

Add below

10.0.3.2 = replace with any unused IP in the range your LXC container assign using DHCP.

Create a static route file

Add

After restarting the LXC container, you will have a fixed IP.

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *