Changes between Initial Version and Version 1 of Yocto/Wireless


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Yocto/Wireless

    v1 v1  
     1[[PageOutline]]
     2
     3= Goal =
     4This page will attempt to guide a user through setting up a wireless connection (both as an AP and as a STA)
     5
     6
     7[=#wireless]
     8= Wireless Info =
     9Our product uses the compat-wireless driver set which provides the most recent drivers from [http://wireless.kernel.org/ linux-wireless] backwards-compatible with older kernel versions.  The following packages are required or at least recommended for wireless:
     10 * iw (recommended) - the [http://wireless.kernel.org/en/users/Documentation/iw iw] tool for interfacing with modern mac80211 based wireless drivers
     11 * wireless-tools (deprecated) - the old toolset for interfacing with legacy wireless drivers (somewhat backwards compatible)
     12 * hostap-daemon - (required for AP mode) the [http://hostap.epitest.fi/hostapd/ hostapd] background daemon app required for AP configuration
     13 * wpa-supplicant - (required for client (STA) mode with encryption) the [http://hostap.epitest.fi/wpa_supplicant/ wpa-supplicant] daemon/app required for client (STA) configuration when using encryption
     14
     15See also:
     16 * [wiki:wireless#WirelessConfigurationStandardLinux Standard Linux Wireless Configuration Commands]
     17
     18
     19[=#wireless-sta]
     20= client configuration (STA) =
     21
     22== Using wpa_passphrase/wpa_supplicant ==
     23In order to connect to a network with WPA encryption, you must use the wpa_supplicant application.  First you must generate a configuration file which is often made easy with the {{{wpa_passphrase}}} application. Then, you must use {{{wpa_supplicant}}} to connect to the network and finally you can configure an IP address (static or dynamic if the AP is running DHCP).  The netbase package provides tools such as ifup/ifdown and a config file /etc/network/interfaces that can configure network on startup.
     24
     25Example:
     261. edit /etc/network/interfaces and edit/add the following to configure wlan0 on boot wpa_supplicant:
     27{{{
     28# Wireless interfaces
     29auto wlan0
     30iface wlan0 inet dhcp
     31        wireless_mode managed
     32        wireless_essid any
     33        #wpa-driver wext
     34        wpa-driver nl80211 # New software makes use of nl80211 over wext!
     35        wpa-conf /etc/wpa_supplicant.conf
     36}}}
     37  * this causes the network interface to be automatically configured on boot (auto wlan), use dhcp for IP address configuration, and run in client mode using wpa supplicant to manage the authentication/encryption keys
     381. configure wpa_supplicant to connect to SSID 'testssid' with no key management.
     39{{{
     40network={
     41        scan_ssid=1
     42        ssid="testssid"
     43        key_mgmt=NONE
     44}
     45}}}
     46 Or with key management:
     47{{{
     48network={
     49        scan_ssid=1
     50        ssid="MYSSID"
     51        proto=WPA
     52        key_mgmt=WPA-PSK
     53        psk="MYWPAPASSCODE"
     54}
     55}}}
     56 You can also generate the wpa_supplicant.conf file using a tool called {{{wpa_passphrase}}}. Below is an example usage:
     57{{{
     58root@ventana:~# wpa_passphrase MYSSID MYWPAPASSCODE
     59network={
     60        ssid="MYSSID"
     61        #psk="MYWPAPASSCODE"
     62        psk=82207641ae13124ee6dc8fd2642605ac52a17405263b0b3203ee5cdb826d700d
     63}
     64root@ventana:~# wpa_passphrase MYSSID MYWPAPASSCODE > /etc/wpa_supplicant.conf
     65}}}
     661. To start manually:
     67{{{
     68killall wpa_supplicant
     69wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
     70}}}
     71 * To start automatically:
     72 Just reboot! The {{{/etc/network/interfaces}}} file we touched above will configure wlan0 to automatically come up with the given options. If you have issues with this, please see the [#Troubleshooting] section below.
     73
     74
     75[=#wireless-ap]
     76= Access Point configuration (AP) =
     77The 'hostap-daemon' package provides the [http://wireless.kernel.org/en/users/Documentation/hostapd hostapd] application which configures the radio for AP mode using configuration from /etc/hostapd.conf.
     78
     79You will need to configure /etc/hostapd.conf to specify important details such as:
     80 * interface
     81 * driver type (the default is nl80211 which is used for all modern mac80211 drivers)
     82 * bridge config
     83 * ssid
     84 * channel
     85 * encryption
     86
     87The default /etc/hostapd.conf file contains detailed documentation and you can find more info [http://wireless.kernel.org/en/users/Documentation/hostapd here]
     88
     89A couple of example configurations:
     90 * a 802.11ac capable card using mac80211 configured for SSID=test-ssid, channel 1, wlan0 interface:
     91{{{
     92cat << EOF > /etc/hostapd.conf
     93interface=wlan0               
     94                               
     95logger_syslog=-1               
     96logger_syslog_level=2         
     97logger_stdout=-1               
     98logger_stdout_level=2         
     99                               
     100ctrl_interface=/var/run/hostapd
     101ctrl_interface_group=0         
     102                               
     103ssid=test-ssid               
     104                               
     105# Spectrum Mode               
     106hw_mode=a                     
     107                               
     108# 0 for ACS                   
     109channel=1                   
     110                               
     111## DFS                         
     112#ieee80211d=1                 
     113#ieee80211h=1                 
     114#country_code=US               
     115
     116# wireless N                                                     
     117ieee80211n=1                                                     
     118ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC2][DSSS_CK-40][LDPC]
     119require_ht=1                                                     
     120                                                                 
     121# wireless ac                                                     
     122ieee80211ac=1                                                     
     123vht_capab=[SHORT-GI-80][HTC-VHT]                                 
     124require_vht=1                                                     
     125vht_oper_chwidth=1                                               
     126# 5.210 GHz                                                       
     127vht_oper_centr_freq_seg0_idx=36                                   
     128# 5.795 GHz                                                       
     129vht_oper_centr_freq_seg1_idx=161                                 
     130
     131EOF
     132/etc/init.d/hostapd stop; sleep 1; /etc/init.d/hostapd start
     133}}}
     134 * a 802.11g capable card using mac80211 (WLE300NX) configured for SSID=testssid, channel 11, wlan0 interface, WPA2 encryption with key=testpass:
     135{{{
     136cat << EOF > /etc/hostapd.conf
     137interface=wlan0
     138ssid=testssid
     139channel=11
     140# encryption
     141wpa=2
     142wpa_passphrase=testpass
     143wpa_key_mgmt=WPA-PSK
     144wpa_pairwise=TKIP
     145rsn_pairwise=CCMP
     146auth_algs=1
     147EOF
     148/etc/init.d/hostapd stop; sleep 1; /etc/init.d/hostapd start
     149}}}
     150
     151Notes:
     152 * Once /etc/hostapd.conf is re-configured reboot or restart the hostapd app:
     153{{{
     154/etc/init.d/hostapd stop
     155sleep 1
     156/etc/init.d/hostapd start
     157}}}
     158 * make sure /etc/network/interfaces is not configuring the wlan interface automatically
     159
     160
     161== bridged Access Point ==
     162A bridged Access Point is used to provide an a Wireless Access Point on a LAN that already has a DHCP server and creates a bridge between the LAN interface and the WIFI interface such that wireless client DHCP requests will be bridged to the LAN and answered from there.
     163
     164For this you need:
     165 * bridge-utils package
     166 * create a bridge between your wifi interface and your lan interface.  For example, assuming wlan0 and eth0:
     167{{{
     168# create a bride and add interfaces to it
     169brctl addbr br0
     170brctl addif br0 eth0
     171brctl addif br0 wlan0
     172# bring it up
     173ifconfig br0 up
     174# use DHCP to assign IP info
     175udhcpc -i br0
     176}}}
     177  * Note that you can use /etc/network/interfaces to bring up and configure the bridge, but if you are using a fairly limited ifup/ifdown (like busybox) you will probably need to create the bridge first (ie in an init script prior to networking coming up)
     178
     179
     180== routed Access Point ==
     181A routed Access Point is used when you want the wireless network to have its own DHCP server and network.  In this case traffic is routed across the LAN and WIFI interfaces.
     182
     183For this you need:
     184 * dnsmasq package (or another DHCP server of your choice)
     185 * the LAN interface (ie eth0) should have an IP configuration from the LAN segment
     186 * the WIFI interface (ie wlan0) should be assigned a static address on a private network
     187 * the dnsmasq server is configured to serve IP addresses on the wlan0 network.
     188
     189Modify the /etc/dnsmasq.conf file. To issue DHCP addresses out the wlan0 be sure the following lines are not commented out and or create them.
     190
     191{{{
     192interface=wlan0
     193}}}
     194{{{
     195dhcp-range=10.0.0.10,10.0.0.200,2h
     196}}}
     197
     198Inside of /etc/network/interfaces, we see a config like so:
     199{{{
     200# Wireless interfaces
     201auto wlan0
     202iface wlan0 inet static
     203        address 10.0.0.1
     204        netmask 255.255.255.0
     205
     206}}}
     207
     208The /etc/hostapd.conf file would look like:
     209{{{
     210interface=wlan0
     211ssid=GateworksDemo
     212channel=11
     213}}}
     214
     215= Troubleshooting =
     216If you're using the above configuration and wireless isn't auto starting in client mode, it's more likely the fault of hostapd also being configured. To disable hostapd, edit /etc/hostapd.conf and remove the wireless interface you would like to use from the "interface" option. Below is a sed that will remove all wireless interfaces from hostapd. This method will allow you to have multiple wireless clients and ap's as you can configure the conf files as needed.
     217{{{
     218sed -i "s/"^interface=.*"/"interface="/" /etc/hostapd.conf
     219}}}