The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

582358 (9) [Avatar] Offline
#1
device : rpi3
network connection : wifi
os : raspbian

Hi there, I followed the book, in chapter 2.3.2, i created a container followed by the command : sudo lxc-create -n myContainer -t ubuntu
It works! Then I use command "sudo lxc-start -d -n mycontainer" to start it, and "sudo lxc-ls --fancy" to see my containers. I see my container is running, but no ip address show up, when i in the container by using command "sudo lxc-attach -n myContainer", i use "ifconfig" to see network status in this container, only "lo" show up and no other network interface, i tried to search on the net by typing like " no ip address from lxc container", and saw some solution, but they all use a cable to connect to the net, i tried to do the same way but i failed. Anyway, i've been trying to solve this problem for several hours, does anyone know how to fix the problem? Im using wifi to connect to the net, and i want my container to get ip address like the example in chapter 2.3.2, and sorry for my poor English, thank you!
David Clinton (92) [Avatar] Offline
#2
Hi,
I suspect the problem might be related to the fact you're running Raspbian - this page (https://superuser.com/questions/1341259/how-do-i-create-a-bridge-interface-on-a-raspberry-pi) suggests that Raspbian doesn't automatically create an LXC bridge on the LXC host. To confirm this, run
ip a
on the host Raspberry Pi and see if there's a bridge listed among the interfaces. It might be called something like
lxdbr0
.
Without a bridge, there's no way your container will get a DHCP address. The page I linked to above has some suggestions for creating a bridge, but I'm afraid I don't have a lot of experience with Raspbian.
Good luck, and let us know how it's going!
582358 (9) [Avatar] Offline
#3
David Clinton wrote:Hi,
I suspect the problem might be related to the fact you're running Raspbian - this page (https://superuser.com/questions/1341259/how-do-i-create-a-bridge-interface-on-a-raspberry-pi) suggests that Raspbian doesn't automatically create an LXC bridge on the LXC host. To confirm this, run
ip a
on the host Raspberry Pi and see if there's a bridge listed among the interfaces. It might be called something like
lxdbr0
.
Without a bridge, there's no way your container will get a DHCP address. The page I linked to above has some suggestions for creating a bridge, but I'm afraid I don't have a lot of experience with Raspbian.
Good luck, and let us know how it's going!

Thank you, now i know it's really the "bridge" problem, i will try on that to see if it worked for me , thank again!
582358 (9) [Avatar] Offline
#4
After several day's trial and error, i finally solve this problem.I finally find a solution from this link:https://s3hh.wordpress.com/2011/05/17/lxc-containers-on-a-host-with-wireless/#comment-4410. And i realized that i can't bridge a wireless NIC (from the link's article), but i keep doing this before knowing that, so i always got a wrong answer. Anyway, here's some content from my settings.
In /etc/network/interfaces:
auto lo
iface lo inet loopback


auto lxcbr0
iface lxcbr0 inet static
    address 192.168.185.10
    netmask 255.255.255.0
    post-up /opt/bin/lxcbr0-up
    bridge_ports none

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


and in /opt/bin/lxcbro-up:
#!/bin/sh
# This is the address we assigned to our bridge in /etc/network/interfaces
braddr=192.168.185.10
# ip address range for containers
brrange=192.168.185.11,192.168.185.254
iptables -A FORWARD -i lxcbr0 -s ${braddr}/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE 
dnsmasq --bind-interfaces --conf-file= --listen-address $braddr --except-interface lo --dhcp-range $brrange --dhcp-lease-max=244 --dhcp-no-override

and followed the article link above, finally i got a container connected to the internet, i'm so happy. Hope this can help others, now i need some rest!
David Clinton (92) [Avatar] Offline
#5
I just noticed your last post. Great to hear you're up and running - and thanks for making the details available to everyone else!
582358 (9) [Avatar] Offline
#6
Thank you!