Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I run a guest with wlan0 nictype=physical? #2165

Closed
epoch1970 opened this issue Jun 29, 2016 · 6 comments

Comments

@epoch1970
Copy link

epoch1970 commented Jun 29, 2016

Hi. I am a beginner, I've looked around and self-help didn't work too well. Here is my question:

On a Raspberry Pi 3, I want to run hostapd in a guest. How can I move the physical wlan0 interface to the guest?
I've been trying:

  • lxc config device add guest wlan0 nic nictype=physical parent=wap0
  • lxc config set guest linux.kernel_modules cfg80211,brcmfmac,brcmutil

to no avail.

Thanks in advance.

Required information

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial

lxc info

apicompat: 0
auth: trusted
environment:
addresses: []
architectures:

  • armv7l
    certificate: |
    -----BEGIN CERTIFICATE-----

    -----END CERTIFICATE-----
    driver: lxc
    driverversion: 2.0.1
    kernel: Linux
    kernelarchitecture: armv7l
    kernelversion: 4.4.0-1016-raspi2
    server: lxd
    serverpid: 2212
    serverversion: 2.0.2
    storage: dir
    storageversion: ""
    config: {}
    public: false
@stgraber

This comment has been minimized.

Copy link
Member

stgraber commented Jun 29, 2016

It depends on the kernel driver. Typically wifi cards are made of two devices, only one of which is visible on the system, a physical device and then the actual wlan device.

The former is usually called phy0 and the latter wlan0. You need to move the physical device into the container which should then automatically bring the wlan device with it.

@epoch1970

This comment has been minimized.

Copy link
Author

epoch1970 commented Jun 29, 2016

Thanks for chiming in Stéphane.
Unfortunately on the Raspberry Pi 3 (driver mac80211, wifi chip BCM43438, SOC BCM2837) I don't see a phy0 device.
I've found an ancient chinese trick that goes to the tune of "iw phy phy0 set netns $pid", and I've had 2 issues with this one:

  • Which PID? I've tried to use the one from "lxd info guest", and that failed
  • Had it worked, I don't know how to (cleanly) automate that.

Fundamentally, I want: the base system to be as slim and standard as possible, the guest to run all my custom stuff, like AP, watchdog, VPN etc. I expect this would give me: i. isolation for my guest (e.g. against IP range clashes), ii. easy deployment/migration for my guest.
Are these expectations correct?

(BTW: I'm reading your blog series on LXD, awaiting the last 2 installments with bated breath :)

@stgraber

This comment has been minimized.

Copy link
Member

stgraber commented Jun 29, 2016

"iw phy phy0 set netns PID" with PID being the one reported in "lxc info" worked fine here using an Intel wifi card, so if that fails for you, it's likely a broadcom driver problem.

@stgraber

This comment has been minimized.

Copy link
Member

stgraber commented Jun 29, 2016

I'm now checking whether there's something we can do to make this work better with LXD

@epoch1970

This comment has been minimized.

Copy link
Author

epoch1970 commented Jun 29, 2016

Ok, if it's only a driver issue (gasp I hope it's not operator error!) then it's looking rather good. Thanks again!

@stgraber

This comment has been minimized.

Copy link
Member

stgraber commented Jun 29, 2016

Ok, so just checked with LXD and things seem to be working as expected on Intel:

stgraber@castiana:~$ lxc start blah
stgraber@castiana:~$ lxc exec blah -- ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:16:3e:0b:1d:ad  
          inet addr:10.212.54.220  Bcast:10.212.54.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe0b:1dad/64 Scope:Link
          inet6 addr: 2001:470:b368:4242:216:3eff:fe0b:1dad/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:42 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6234 (6.2 KB)  TX bytes:1312 (1.3 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:1504 (1.5 KB)  TX bytes:1504 (1.5 KB)

stgraber@castiana:~$ lxc config device add blah wlan0 nic nictype=physical parent=wlan0 name=wlan0
Device wlan0 added to blah
stgraber@castiana:~$ lxc exec blah -- ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:16:3e:0b:1d:ad  
          inet addr:10.212.54.220  Bcast:10.212.54.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe0b:1dad/64 Scope:Link
          inet6 addr: 2001:470:b368:4242:216:3eff:fe0b:1dad/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:125 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:15542 (15.5 KB)  TX bytes:1476 (1.4 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:1504 (1.5 KB)  TX bytes:1504 (1.5 KB)

wlan0     Link encap:Ethernet  HWaddr 44:85:00:84:60:de  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:6514488 errors:0 dropped:10 overruns:0 frame:0
          TX packets:6420066 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6502505975 (6.5 GB)  TX bytes:4998102057 (4.9 GB)
@stgraber stgraber closed this Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.