[lxc-users] lxcbr0?

Mark Constable markc at renta.net
Thu Nov 19 00:34:46 UTC 2015


On 18/11/15 08:22, Robert Koretsky wrote:
> I have successfully installed and created/started LXC containers on Ubuntu 15.10,
>  but cannot get them to be visible on my home network. I do an ifconfig on both
>  the host and in a container, and see the IPv4 address of lxcbr0 as 10.0.3.1,
>  but after reading many references cannot figure out how to get my router to
>  assign the container an address, like 192.168.0.20 say.

There are a number of ways to do this. This is my approach where my router/modem
is at 192.168.0.1...

. edit /etc/default/lxc-net  and set USE_LXC_BRIDGE="false"
. edit /etc/network/interfaces and add...

auto enp4s0f1 # or eth0
iface enp4s0f1 inet manual
auto lxcbr0
iface lxcbr0 inet static
   address 192.168.0.2
   netmask 255.255.255.0
   gateway 192.168.0.1
   dns-nameserver 192.168.0.2
   dns-search example.org
   bridge_ports enp4s0f1
   bridge_stp on
   bridge_fd 1
   bridge_maxwait 1
#auto wlp3s0 # or wlan0
#iface wlp3s0 inet static
#  address 192.168.0.2
#  netmask 255.255.255.0
#  broadcast 192.168.0.255
#  gateway 192.168.0.1
#  dns-nameserver 192.168.0.2
#  dns-search example.org
#  wpa-ssid "MY AP"
#  wpa-psk xxxxxxxxxxxx

. you may need to "systemctl enable networking" and disable NetworkManager
. edit /etc/dnsmasq.conf as something like this...

domain-needed
bogus-priv
no-resolv
no-hosts
expand-hosts
cache-size=10000
local-ttl=120
log-async=10
dns-loop-detect
dhcp-authoritative
log-queries
log-dhcp
bind-interfaces
server=8.8.8.8
server=8.8.4.4

# switch between wifi and lan-bridge
interface=lxcbr0
server=192.168.0.2 at lxcbr0
#interface=wlp3s0
#server=192.168.0.2 at wlp3s0

dhcp-option=option:router,192.168.0.1
addn-hosts=/etc/addn-hosts
domain=example.org
server=/mbox.goldcoast.org/192.168.0.2
server=/0.168.192.in-addr.arpa/192.168.0.2
local=/goldcoast.org/
address=/my.example.org/192.168.0.2
address=/lxc1.example.org/192.168.0.3
address=/lxc2.example.org/192.168.0.4
address=/lxc3.example.org/192.168.0.5
mx-host=example.org,lxc1.example.org,10
dhcp-range=192.168.0.3,192.168.0.99,255.255.255.0,12h
dhcp-host=lxc1,192.168.0.3,12h
dhcp-host=lxc2,192.168.0.4,12h
dhcp-host=lxc3,192.168.0.5,12h

So that you can use this particular dnsmasq setup for wifi-only access (which
can't be bridged unfortunately) where it's great for local DNS caching aside
from being used as the DHCP server for containers.



More information about the lxc-users mailing list