| 1 | [[PageOutline]] |
| 2 | |
| 3 | = Goal = |
| 4 | This 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 = |
| 9 | Our 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 | |
| 15 | See 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 == |
| 23 | In 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 | |
| 25 | Example: |
| 26 | 1. edit /etc/network/interfaces and edit/add the following to configure wlan0 on boot wpa_supplicant: |
| 27 | {{{ |
| 28 | # Wireless interfaces |
| 29 | auto wlan0 |
| 30 | iface 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 |
| 38 | 1. configure wpa_supplicant to connect to SSID 'testssid' with no key management. |
| 39 | {{{ |
| 40 | network={ |
| 41 | scan_ssid=1 |
| 42 | ssid="testssid" |
| 43 | key_mgmt=NONE |
| 44 | } |
| 45 | }}} |
| 46 | Or with key management: |
| 47 | {{{ |
| 48 | network={ |
| 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 | {{{ |
| 58 | root@ventana:~# wpa_passphrase MYSSID MYWPAPASSCODE |
| 59 | network={ |
| 60 | ssid="MYSSID" |
| 61 | #psk="MYWPAPASSCODE" |
| 62 | psk=82207641ae13124ee6dc8fd2642605ac52a17405263b0b3203ee5cdb826d700d |
| 63 | } |
| 64 | root@ventana:~# wpa_passphrase MYSSID MYWPAPASSCODE > /etc/wpa_supplicant.conf |
| 65 | }}} |
| 66 | 1. To start manually: |
| 67 | {{{ |
| 68 | killall wpa_supplicant |
| 69 | wpa_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) = |
| 77 | The '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 | |
| 79 | You 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 | |
| 87 | The default /etc/hostapd.conf file contains detailed documentation and you can find more info [http://wireless.kernel.org/en/users/Documentation/hostapd here] |
| 88 | |
| 89 | A couple of example configurations: |
| 90 | * a 802.11ac capable card using mac80211 configured for SSID=test-ssid, channel 1, wlan0 interface: |
| 91 | {{{ |
| 92 | cat << EOF > /etc/hostapd.conf |
| 93 | interface=wlan0 |
| 94 | |
| 95 | logger_syslog=-1 |
| 96 | logger_syslog_level=2 |
| 97 | logger_stdout=-1 |
| 98 | logger_stdout_level=2 |
| 99 | |
| 100 | ctrl_interface=/var/run/hostapd |
| 101 | ctrl_interface_group=0 |
| 102 | |
| 103 | ssid=test-ssid |
| 104 | |
| 105 | # Spectrum Mode |
| 106 | hw_mode=a |
| 107 | |
| 108 | # 0 for ACS |
| 109 | channel=1 |
| 110 | |
| 111 | ## DFS |
| 112 | #ieee80211d=1 |
| 113 | #ieee80211h=1 |
| 114 | #country_code=US |
| 115 | |
| 116 | # wireless N |
| 117 | ieee80211n=1 |
| 118 | ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC2][DSSS_CK-40][LDPC] |
| 119 | require_ht=1 |
| 120 | |
| 121 | # wireless ac |
| 122 | ieee80211ac=1 |
| 123 | vht_capab=[SHORT-GI-80][HTC-VHT] |
| 124 | require_vht=1 |
| 125 | vht_oper_chwidth=1 |
| 126 | # 5.210 GHz |
| 127 | vht_oper_centr_freq_seg0_idx=36 |
| 128 | # 5.795 GHz |
| 129 | vht_oper_centr_freq_seg1_idx=161 |
| 130 | |
| 131 | EOF |
| 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 | {{{ |
| 136 | cat << EOF > /etc/hostapd.conf |
| 137 | interface=wlan0 |
| 138 | ssid=testssid |
| 139 | channel=11 |
| 140 | # encryption |
| 141 | wpa=2 |
| 142 | wpa_passphrase=testpass |
| 143 | wpa_key_mgmt=WPA-PSK |
| 144 | wpa_pairwise=TKIP |
| 145 | rsn_pairwise=CCMP |
| 146 | auth_algs=1 |
| 147 | EOF |
| 148 | /etc/init.d/hostapd stop; sleep 1; /etc/init.d/hostapd start |
| 149 | }}} |
| 150 | |
| 151 | Notes: |
| 152 | * Once /etc/hostapd.conf is re-configured reboot or restart the hostapd app: |
| 153 | {{{ |
| 154 | /etc/init.d/hostapd stop |
| 155 | sleep 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 == |
| 162 | A 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 | |
| 164 | For 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 |
| 169 | brctl addbr br0 |
| 170 | brctl addif br0 eth0 |
| 171 | brctl addif br0 wlan0 |
| 172 | # bring it up |
| 173 | ifconfig br0 up |
| 174 | # use DHCP to assign IP info |
| 175 | udhcpc -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 == |
| 181 | A 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 | |
| 183 | For 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 | |
| 189 | Modify 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 | {{{ |
| 192 | interface=wlan0 |
| 193 | }}} |
| 194 | {{{ |
| 195 | dhcp-range=10.0.0.10,10.0.0.200,2h |
| 196 | }}} |
| 197 | |
| 198 | Inside of /etc/network/interfaces, we see a config like so: |
| 199 | {{{ |
| 200 | # Wireless interfaces |
| 201 | auto wlan0 |
| 202 | iface wlan0 inet static |
| 203 | address 10.0.0.1 |
| 204 | netmask 255.255.255.0 |
| 205 | |
| 206 | }}} |
| 207 | |
| 208 | The /etc/hostapd.conf file would look like: |
| 209 | {{{ |
| 210 | interface=wlan0 |
| 211 | ssid=GateworksDemo |
| 212 | channel=11 |
| 213 | }}} |
| 214 | |
| 215 | = Troubleshooting = |
| 216 | If 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 | {{{ |
| 218 | sed -i "s/"^interface=.*"/"interface="/" /etc/hostapd.conf |
| 219 | }}} |