LXC Container with Bridged Network from Host

LXC HOST: UBUNTU Server 13.04
GNU/Linux 3.8.0-25-generic x86_64

UPDATE & UPGRADE 1ST!!
sudo apt-get update -f
sudo apt-get upgrade

Install LXC and OpenSSH Server
sudo apt-get install lxc openssh-server
Disable & Stop Network Manager
(sever editions can skip silliness & build a bridge)
sudo service network-manager stop
sudo nano /etc/NetworkManager/NetworkManager.conf
managed=true
Bridge Interfaces & Assign Static IP
sudo nano /etc/network/interfaces

iface eth0 inet manual
auto br0
iface br0 inet static
    address 192.168.27.18
    network 192.168.27.0
    netmask 255.255.255.0
    broadcast 192.168.27.255
    gateway 192.168.27.1
    bridge_ports eth0
    bridge_fd 9
    bridge_hello 2
    bridge_maxage 12
    bridge_stp off
    dns-nameservers 192.168.27.1 8.8.8.8 8.8.4.4
Bounce Interfaces & Restart Network Services
sudo ifdown eth0
sudo ifup br0
sudo service networking restart
Edit Default LXC Config & Create a new container
sudo nano /etc/lxc/default.conf
lxc.network.link=br0
sudo lxc-create  -t ubuntu -n zap00
Start Container (get IP, test, & shutdown)
sudo lxc-start -n zap00
Login: ubuntu
Password: ubuntu
ubuntu@zap00:~$ ifconfig eth0
eth0    Link encap:Ethernet  HWaddr 00:16:3e:be:52:14
        inet addr:192.168.27.19 Bcast:192.168.27.255 Mask:255.255.255.0
        inet6 addr: fe80::216:3eff:febe:5214/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:2313 errors:0 dropped:0 overruns:0 frame:0
        TX packets:118 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:341585 (341.5 KB)  TX bytes:16671 (16.6 KB)
ubuntu@zap00:~$ ping www.google.com
PING www.google.com (173.194.75.99) 56(84) bytes of data.
64 bytes from ve-in-f99.1e100.net (173.194.75.99): icmp_req=1 ttl=250 time=20.1 ms
ubuntu@zap00:~$ sudo shutdown -h now
Start Container (daemon mode)
billreed@macbook:~$ sudo lxc-start -d -n zap00
ZAP00 Container Host: SSH into the container
billreed@macbook:~$ ssh ubuntu@192.168.27.19
ubuntu@192.168.27.19's password: ubuntu
ubuntu@zap01:~$ _
Quick Install of Webmin (just for fun... why not?)
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python wget
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.690_all.deb
sudo dpkg -i webmin_1.690_all.deb
Now you can access https://192.168.27.19:10000/ from another computer on the same network.

Comments

Popular Posts