Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Ok, so I want to know how to do networking on LXC containers. Not just the sort of vague information you get from the other websites, but a true beginner's guide to making them work.. Since most examples are basically setup for people to test with, I want to run a service on one...like a web server for example.

I am running Ubuntu 12.04 LTS and I have LXC installed and I can make, start and stop a container. My server obviously has a public facing IP and I would like to know how to setup a container so it too can have a public IP. Since there already seems to be a bridge in place from my current container it would seem that I either need to give the containers a DHCP range that is public for them to work off or manually assign a static IP address to my container.

If I want to statically assign an IP to the container, how do I do that? Do I need to make any changes to my bridge config on the host? Is it actually better to do it with the MACVLAN option?

Any help would be appreciated.

share|improve this question
I'm not familiar with LXC, but your typically isp is only going to give you one public IP address. Do you have a package with multiple static ips? – wlraider70 Mar 21 at 19:20
Public facing IPs aren't the only use case, we want 2 public IPs to be assigned to our load balancer containers, but we want dedicated LAN IPs dedicated to a variety of other services. That way if we move containers around on different hardware it's as easy as moving the IP (DNS doesn't work in this respect for some of the components we use) – David Parks Mar 22 at 12:32

1 Answer

You cannot directly get static IP. You need to request your ISP for that. And the ISP would charge you some money for that.
As far as the IP of the LXC box is concerned you can use this script for that.
How to go about with this scipt:

$ chmod u+x getip.sh
$ ./getip.sh

Then you will see the IP of you LXC box. But you have to run this command inside the LXC box.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.