Hi everyone,
So I’m getting started with LXD (super cool BTW, thank you all!) and to get my feet wet I decided to setup an all-in-one home-media-server/firewall doodah on a small mini-pc I had lying around, for the host OS I’m running Arch Linux (BTW ) on the latest zen kernel and for networking I’m using systemd-networkd and systemd-resolved.
Everything is working fine except for 2 things:
1- cannot pass a physical wifi device from host to container (ethernet works just fine though)
2- cannot reach the internet from the host even though host and openwrt can communicate (tested using iperf)
So here’s exactly what I’ve done so far:
1. setup a bridge device on the host to act as an internal switch
#/etc/systemd/network/br0.netdev
[NetDev]
Name=br0
Kind=bridge
#/etc/systemd/network/br0.network
[Match]
Name=br0
[Link]
MTUBytes=9000
[Network]
DHCP=yes
2. enable LXD socket:
systemctl enable --now lxd.socket
2.1 Initialize LXD using:
lxd init
(without the default bridge).
3. create an OpenWrt instance:
lxc launch images:openwrt/21.02 openwrt
3.1 add a wan interface:
lxc config device add openwrt eth0 nic nictype=physical parent=eno1 name=eth0
3.2 add a lan interface:
lxc config device add openwrt eth1 nic nictype=bridged parent=br0 name=eth1
3.3 add a wireless lan interface:
lxc config device add openwrt wlan nic nictype=physical parent=wlan0 name=wlan
Error: Failed to start device “wlan”: Failed to attach interface: wlan0 to wlan: attaching specified netdev to the container failed
3.4 enable autostart:
lxc config set openwrt boot.autostart true
3.5 set boot priority:
lxc config set openwrt boot.autostart.priority 100
4. restart openwrt:
lxc restart openwrt
5. connect to the OpenWrt web interface and configure wan and lan on eth0 and eth1 respectively (by default eth0 gets assigned as wan).
5.1 make OpenWrt is able to reach the internet. (e.g. ping google.com)
5.2 refresh package list and upgrade packages:
opkg update && opkg upgrade $(opkg list-upgradable | cut -d " " -f 1)
5.3 install iperf
opkg install iperf
5.4 run iperf in server mode
iperf -s &
5.5 find out what ip address was assigned to host on lan:
cat /tmp/dhcp.leases
5.6 ssh into host:
ssh <user>@<assigned ip>
5.7 test connection between host and openwrt:
iperf -c <openwrt-ip> -P $(nproc)
5.8 check if host can reach the internet
ping google.com
or ping 8.8.8.8