I am attempting to use LXC containers with OpenVswitch on Ubuntu 18.04 LTS
server.  However, I am unable to work out the syntax for the container
settings.  The container is failing to start due to unable to create the
network.

I did a vanilla install onto a media play with two NIC cards - enp1s0 and
enp2s0.

I installed, created, tested and then destroyed a container using lxc to
confirm that lxc was functioning correctly on the server.

#sudo apt-get install lxc lxc-templates wget bridge-utils
#sudo lxc-checkconfig
#sudo lxc-create -n vm1 -t ubuntu
#sudo lxc-start -n vm1
#sudo lxc-console -n vm1
#sudo lxc-stop -n vm1
#sudo lxc-destroy -n vm1

I then removed lxc bridge - lxcbr0 by setting USE_LXC_BRIDGE to false in
/etc/default/lxc-net and removed lxcbr0 device and rebooted.

# sudo ip link set lxcbr0 down
# sudo brctl delbr lxcbr0

I then installed openvswitch and created two bridges br-dmz (dmz
containers - 172.18.0.0/24) and br-int (internal containers -
192.168.0.0/24).  I have added physical NIC port enp2s0 to br-int as I
have a local WAP installed on that interface.

#sudo apt-get install openvswitch-switch
#sudo ovs-vsctl add-br br-dmz
#sudo ovs-vsctl add-br br-int
#sudo ovs-vsctl add-port br-int enp2s0

#sudo ip addr add 172.18.0.1/24 dev br-dmz
#sudo ip addr add 192.168.10.1/24 dev br-int

#sudo ovs-vsctl show
c3d9247e-68f1-4ae1-be0e-4bb86fd2c541
    Bridge br-dmz
        Port br-dmz
            Interface br-dmz
                type: internal
    Bridge br-int
        Port br-int
            Interface br-int
                type: internal
        Port "enp2s0"
            Interface "enp2s0"
    ovs_version: "2.9.0"

#ip a

5: br-dmz: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
default qlen 1000
    link/ether 7e:86:2a:79:24:4e brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/24 scope global br-dmz
       valid_lft forever preferred_lft forever
6: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
default qlen 1000
    link/ether 00:01:80:82:f8:59 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.1/24 scope global br-int
       valid_lft forever preferred_lft forever


I created a LXC container VM1 and I would like to attach to br-int

sudo lxc-create -n vm1 -t ubuntu

Edit VMs config vi /var/lib/lxc/vm1/config

lxc.net.0.link = br-int    <- from lxcbr0
lxc.net.0.script.up=/etc/lxc/ifup       <- added
lxc.net.0.script.down=/etc/lxc/ifdown   <- added

Created scripts to ifup / ifdown interface

vi /etc/lxc/ifup
#!/bin/bash
BRIDGE=br-int
ovs-vsctl --may-exist add-br $BRIDGE
ovs-vsctl --if-exists del-port $BRIDGE $5
ovs-vsctl --may-exist add-port $BRIDGE $5

vi /etc/lxc/ifdown
#!/bin/bash
ovsBr=br-int
ovs-vsctl --if-exists del-port ${ovsBr} $5

chmod +x /etc/lxc/if*

When I try to start the container using openvswitch I get the following
error.

sudo lxc-start -n vm1 --logfile log.txt

lxc-start vm1 20180512072653.582 ERROR    lxc_conf - conf.c:run_buffer:347
- Script exited with status 1
lxc-start vm1 20180512072653.610 ERROR    lxc_network -
network.c:lxc_create_network_priv:2436 - Failed to create network device
lxc-start vm1 20180512072653.610 ERROR    lxc_start -
start.c:lxc_spawn:1545 - Failed to create the network
lxc-start vm1 20180512072653.610 ERROR    lxc_start -
start.c:__lxc_start:1866 - Failed to spawn container "vm1"
lxc-start vm1 20180512072653.610 ERROR    lxc_container -
lxccontainer.c:wait_on_daemonized_start:824 - Received container state
"STOPPING" instead of "RUNNING"


Any idea what I have missed that is causing the container netwok to not be
created.

Thanks

Densha










_______________________________________________
discuss mailing list
disc...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss

Reply via email to