734a735,1077
>     <section id="sect.wireless-client">
>       <title>Wireless Client Configuration</title>
> 
>       <para>Wireless Fidelity (WiFi) enable a Debian machine to connect
>       to a wireless access point (AP) such as a router. In Debian, there
>       are two ways of connecting to an AP. The first is manual configuration.
>       While manually configuring a wireless interface involves more work and
>       resets after every reboot, it works on all Linux distributions and
>       is important to know when troubleshooting wireless issues. Manually
>       configuring a wireless client can be broken into three steps:
>       ensure the wireless interface is detected and functional, connect
>       and authenticate to the AP, and obtain an IP address.
>       </para>
> 
>       <para>In order for a wireless device to be detected by Debian, the
>       kernel must have support for the device and the correct firmware
>       needs to be installed. To determine if the wireless interface is
>       detected, run lsusb for a usb based wireless adapter or lspci for
>       a pci based wireless adapter.
>       </para>
>       
>       <example id="example.wireless-client-lsusb">
>           <title>Example lsusb output</title>
>           <programlisting>
> root@~-> lsusb
> ...
> Bus 001 Device 002: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
> ...
>           </programlisting>
>       </example>
> 
>       <para>The wireless interface should be listed in the output of ip addr.</para>
>       <example id="example.wireless-client-ipaddr">
>           <title>Example ip addr output</title>
>           <programlisting>
> root@~-> ip addr
> 1: wlan0: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc mq state DOWN group default qlen 1000
>     link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
>           </programlisting>
>       </example>
> 
>       <para>If your wireless device is not listed in either lsusb/lspci
>       or ip addr, then the device is not being detected by the kernel.
>       Most likely, the kernel does not have support compiled in for the 
>       wireless device. To enable support, you will need to compile a custom
>       kernel. In the kernel configuration menu, go to Device Drivers -> 
>       Network Device Support -> Wirless LAN and enable the drivers needed
>       for your wireless device. There may also be wireless drivers in
>       Device Drivers -> Staging Drivers.  Some wireless chipsets
>       (such as for the RT5370 device in the example output) require closed
>       source firmware. To install this firmware, enable the non-free
>       repository in /etc/apt/sources.list, run apt-get update, and install
>       the firmware required. For the specific RT5370 chipset in the example,
>       the firmware-ralink package is needed. To find information about your
>       specific wireless chipset, see https://wiki.debian.org/WiFi.
>       </para>
>     
>       <para>Now that the wireless interface is detected by the kernel,
>       it can be connected to an AP. As an example, "wlan0" will be the
>       wireless interface name, "AP" will be the name of the AP to connect
>       to, "qwert" will be the password for the WEP AP and "password"
>       will be the password for the WPA AP. Adjust accordingly.
>       </para>
> 
>       <para>Set the wireless interface up</para>
>       <example id="example.wireless-client-interface-up">
>          <title>Set interface up</title>
>          <programlisting>
> root@~-> ip link set wlan0 up
>          </programlisting>
>       </example>
> 
>       <para>An AP can require one of three authentication methods: open,
>       WEP, and WPA. Open authentication require no authentication at all; 
>       any client within range can connect to an open AP. 
>       WEP encryption is obsolete and can be broken in a matter of minutes. 
>       While WEP should never be used to secure an AP, it is included here 
>       for completeness. WPA is the prefered method of authentication for an AP. 
>       </para>
>  
>       <example id="example.wireless-client-open-setup">
>          <title>For open authentication</title>
>          <programlisting>
> root@~-> iwconfig wlan0 essid AP
>          </programlisting>
>       </example>
> 
>       <example id="example.wireless-client-WEP-setup">
>          <title>For WEP authentication</title>
>          <programlisting>
> root@~-> iwconfig wlan0 essid AP key s:qwert
>          </programlisting>
>       </example>
> 
>       <example id="example.wireless-client-WPA-setup">
>          <title>For WPA authentication</title>
>          <programlisting>
> root@~-> #Generate a configuration with
> root@~-> wpa_passphrase AP password > /etc/wpa_supplicant.conf
> root@~-> #Connect to the access point with
> root@~-> wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf
> root@~-> #This may generate some warnings that can be ignored for now.
>          </programlisting>
>       </example>
> 
>       <para>The wireless interface now needs to obtain an ip address.</para>
>       <example id="example.wireless-client-static-ip">
>          <title>For a static IP address</title>
>          <programlisting>
> root@~-> #Replace 192.168.1.2 with the desired ip address
> root@~-> #and /24 with the required netmask.
> root@~-> ip addr add 192.168.1.2/24 dev wlan0
>          </programlisting>
>       </example>
>       <example id="example.wireless-client-dhcp-ip">
>          <title>For a DHCP IP address</title>
>          <programlisting>
> root@~-> dhcpcd wlan0
>          </programlisting>
>       </example>
> 
>       <para>The client is now connected to the AP. However, the kernel has
>       not been configured to use this as the default route. To make the
>       wireless interface the default, execute
>       </para>
>       <example id="example.wireless-client-add-route">
>          <title>Set default route</title>
>          <programlisting>
> root@~-> #Replace 192.168.1.1 with the IP address of your gateway
> root@~-> ip route del default via 192.168.1.1
> root@~-> ip route add default via 192.168.1.1 dev wlan0
>          </programlisting>
>       </example>
> 
>       <para>The client is now connected. If pinging an ip address such as
>       8.8.8.8 works, but pinging a hostname such as google.com does not,
>       then adjust /etc/resolv.conf to include the domain and nameserver.
>       </para>
> 
>       <para>A wireless interface can also be configured using 
>       /etc/network/interfaces. This method is simpler than manual configuration
>       and is automatically setup on every boot. The examples below will need
>       to be changed according to the network setup. Note that in order for
>       the wireless interface to be the default route, it must come before
>       other entries in /etc/network/interfaces. For the examples below,
>       choose either the static or dhcp configuration. 
>       </para>
> 
>       <example id="example.wireless-client-open-config">
>           <title>For an open AP</title>
>           <programlisting>
> #DHCP configuration
> auto wlan0
> iface wlan0 inet dhcp
>   wireless-essid AP
> 
> #Static configuration
> auto wlan0 
> iface wlan0 inet static
>   address 192.168.1.2
>   netmask 255.255.255.0
>   gateway 192.168.1.1
>   broadcast 192.168.1.255
>   network 192.168.1.0
>   wireless-essid AP
>            </programlisting>
>       </example>
> 
>       <example id="example.wireless-client-WEP-config">
>          <title>For a WEP AP</title>
>          <programlisting>
> #DHCP configuration
> auto wlan0
> iface wlan0 inet dhcp
>   wireless-essid AP
>   wireless-key s:qwert
> 
> #Static configuration
> auto wlan0
> iface wlan0 inet static
>   address 192.168.1.2
>   netmask 255.255.255.0
>   gateway 192.168.1.1
>   broadcast 192.168.1.255
>   network 192.168.1.0
>   wireless-essid AP
>   wireless-key s:qwert
>           </programlisting>
>        </example>
>       
>        <example id="example.wireless-client-WPA-config">
>           <title>For a WPA AP</title>
>           <programlisting>
> #DHCP configuration
> auto wlan0
> iface wlan0 inet dhcp
>   wpa-conf /etc/wpa_supplicant.conf
> 
> #Static configuration
> auto wlan0
> iface wlan0 inet static 
>   address 192.168.1.2
>   netmask 255.255.255.0
>   gateway 192.168.1.1
>   broadcast 192.168.1.255
>   network 192.168.1.0
>   wpa-conf /etc/wpa_supplicant.conf
>           </programlisting>
>        </example>
> 
>        <para>Finally, restart the network</para>
>        <example id="example.wireless-client-restart">
>           <title>Restart the network</title>
>           <programlisting>
> root@~-> systemctl restart network
>           </programlisting>
>        </example>
>        <para>The wireless interface is now configured and will be activated
>        on every boot.
>        </para>
>   </section> 
> 
>     
> 
>   <section id="sect.wireless-AP">
>     <title>Wireless Access Point Configuration</title>
> 
>     <para>Running a wireless access point (AP) on Debian allows
>     wireless clients to connect. This can be useful for
>     setting up a wireless router or creating a local wireless network.
>     </para>
> 
>     <para>In addition to ensuring that the wireless device is detected
>     by the kernel, the device must also support AP mode. To check if your
>     device does, run
>     </para>
> 
>     <example id="example.wireless-AP-check">
>        <title>Check for AP mode</title>
>        <programlisting>
> root@~-> iw phy
>    ...
>    software interface modes (can always be added):
>               * AP/VLAN
>    ...
>        </programlisting>
>      </example>
> 
>      <para>If the wireless device supports AP mode, then there should
>      be an "AP/VLAN" entry under "software interface modes." If there is no such
>      entry, then the wireless device cannot act as an access point. 
>      </para>
> 
>      <para>Install hostapd and open a file named /etc/hostapd/hostapd.conf.
>      Change "wlan0" to your wireless interface name and "MYNET" to the
>      desired network name. The configurations below are templates. For more
>      information about configuring hostapd, see 
>      https://wireless.wiki.kernel.org/en/users/Documentation/hostapd
>      </para>
> 
>      <example id="example.wireless-AP-hostapd-open-config">
>         <title>For an open AP</title>
>         <programlisting>
> interface=wlan0
> driver=nl80211
> ssid=MYNET
> hw_mode=g
> channel=6
> auth_algs=1
>         </programlisting>
>      </example>
>    
>      <example id="example.wireless-AP-hostapd-WEP-config">
>         <title>For a WEP AP</title>
>         <programlisting>
> interface=wlan0
> driver=nl80211
> ssid=MYNET
> hw_mode=g
> channel=6
> auth_algs=2
> wep_default_key=0
> wep_key0="qwert"
>         </programlisting>
>      </example>
> 
>      <sidebar>
>        <title><emphasis>NOTE</emphasis> WEP Key Length</title>
>        <para>Due to how WEP functions, passwords can only be 
>        5 or 13 charachters long. Any other length is invalid and
>        hostapd will fail to start.
>        </para>
>      </sidebar>
> 
>      <example id="example.wireless-AP-hostapd-wpa-config">
>         <title>For a WPA AP</title>
>         <programlisting>
> interface=wlan0
> driver=nl80211
> ssid=MYNET
> hw_mode=g
> channel=6
> auth_algs=1
> wpa=3
> wpa_passphrase=password
> wpa_key_mgmt=WPA-PSK
> wpa_pairwise=TKIP
> rsn_pairwise=CCMP
>         </programlisting>
>       </example>
> 
>       <para>Start the AP.</para>
>       <example id="example.wireless-AP-start">
>          <title>Start the AP</title>
>          <programlisting>
> root@~-> hostapd /etc/hostapd/hostapd.conf
>          </programlisting>
>       </example>
> 
>       <para>Finally, assign a static IP address so that connected client
>       can directly connect to the AP.</para>
>       <example id="example.wireless-AP-static-ip">
>          <title>Add static IP</title>
>          <programlisting>
> root@~-> ip addr add 192.168.1.1/24 dev wlan0
>          </programlisting>
>       </example>
> 
>       <para>The wireless access point is now setup. A dhcp server 
>       such as dnsmasq can be setup on the wireless interface to handle
>       dhcp clients.
>       </para>
> 
>      <sidebar>
>       <title><emphasis>NOTE</emphasis> Troubleshooting</title>
>       <para>If you encounter any problems in setting up the AP,
>       ensure that the IP subnet is not already in use.
>       For example, if a local wireless network is operating on the 
>       192.168.1.x subnet, your AP should operate under a different
>       subnet. 
>       </para>
>      </sidebar>
>     </section>
735a1079
> 
