Wireless
Wireless Station
The default configuration for the wireless station interface is defined in /etc/network/interfaces.d/wlan0. The configuration specifies interface bring-up behavior, including starting the DHCP client for the device and setting the network configuration file for the WPA supplicant:
auto wlan0 iface wlan0 inet manual pre-up ifconfig $IFACE up post-up dhclient -nw $IFACE wpa-conf /etc/wpa_supplicant.conf wpa-driver nl80211 wpa-options -B
Bringing up Wireless Interface
The wireless interface (most commonly wlan0) can be brought up manually with:
ifconfig <interface> up
To check the naming of the interfaces available, including those that have yet to be brought up, the -a flag can be used.
$ ifconfig -a
lo Link eoopback 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:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropps:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr e0:e5:cf:00:ff:22 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Wireless Naming Rules
The wireless naming will automatically be enumerated by udev based on hardware address within /etc/udev/rules.d/70-persistent-net.rules. udev will create a new and unique name for the interface if it is not listed within this rules file. This will ensure that the interface name will always be the same when the system boots up. Removing the list of interfaces from within this file will cause udev to regenerate interface names on the next reboot. In the following example, a name of "wlan0" has been given to the wireless interface:
# This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # Unknown net device (/devices/amba.2/e000b000.ps7-ethernet/net/eth0) (xemacps) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0a:35:00:01:22", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # Unknown net device (/devices/soc0/amba/e0101000.sdhci/mmc_host001/mmc1:0001:2/wl18xx.0.auto/net/wlan0) (wl18xx_driver) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e0:e5:cf:00:ff:22", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
Wireless Configuration on Boot
The wireless interface bring-up behaviour can be configured within /etc/network/interfaces.d.
Connecting to Networks (wpa_supplicant)
A network connection can be established by starting the wpa_supplicant daemon. The WPA supplicant requires a configuration file with a list of network configurations to use for connection.
$ wpa_supplicant -B -Dnl80211 -iwlan1 -c/etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
Checking Network Connection
iw dev <interface> link
If connected to a network the output will show the details of the connection:
$ iw dev wlan0 link
Connected to 12:34:56:78:9a:bc (on wlan0) SSID: MyNetwork freq: 2437 RX: 32843 bytes (117 packets) TX: 1303 bytes (12 packets) signal: -44 dBm tx bitrate: 150.0 MBit/s MCS 7 40MHz short GI bss flags: short-preamble short-slot-time dtim period: 1 beacon int: 100
$ iw dev wlan0 link
Not connected.
Getting an IP Address (dhclient)
dhclient <interface>
Checking IP Address and Connectivity
Checking Interface Configuration/Connection (ifconfig)
$ ifconfig
wlan0 Link encap:Ethernet HWaddr e0:e5:cf:00:ff:22 inet addr:10.0.111.160 Bcast:10.0.111.255 Mask:255.255.255.0 inet6 addr: fe80::e2e5:cfff:fe00:ff22/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:201 errors:0 dropped:0 overruns:0 frame:0 TX packets:11 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:54949 (54.9 KB) TX bytes:1526 (1.5 KB)
Checking Internet Connection (ping)
$ ping google.com
PING google.com (216.58.194.206) 56(84) bytes of data. 64 bytes from sfo03s01-in-f14.1e100.net (216.58.194.206): icmp_seq=1 ttl=54 time=18.0 ms
Network Interface Configuration
Files defining the network configuration information can be created within the /etc/network/interfaces.d directory which is sourced when ifup -a
is run (typically from within the network boot script sourced from /etc/init.d/networking). The following example brings up the interface on boot up by identifying the inteface with auto wlan0
. The rules defined after iface wlan0 inet manual
specify the the set of commands to execute as the interface is controlled by the system. The commands described earlier have been combined to automatically bring up the interface and use the WPA supplicant to connect to available networks listed in the configuration file /etc/wpa_supplicant.conf.
#### wlan0 configuration #### auto wlan0 iface wlan0 inet manual pre-up ifconfig $IFACE up up wpa_supplicant -B -Dnl80211 -i$IFACE -c/etc/wpa_supplicant.conf up dhclient $IFACE down ifconfig $IFACE down
The combination of files within /etc/network/interfaces.d and the /etc/udev/rules.d/70-persistent-net.rules create the rules for naming and controlling the bring-up/down of the network interfaces.
Wireless Access Point
Network Interface Configuration
auto wlan1 iface wlan1 inet static address 10.0.110.2 netmask 255.255.255.0 hostapd /etc/hostapd.conf
Hostapd
ifupdown Script
A script responsible for bringing up the hostapd resides in the /etc/network/if-up.d directory for execution after the network interface has been brought up. The hostapd
stanza of the network interface configuration is what acts as the switch for the hostapd script. The script is responsible for, in addition to bringing up the access point, setting the default SSID in hostapd.conf. If the SSID has not already been set when the hostapd script is executed, a default SSID will be generated using the last 6 octets of the interface MAC address. If the SSID has already been set, either by a previous execution of the script, or by the user, the script does not modify the SSID.
if-up.d/hostapd --> /etc/hostapd/ifupdown.sh
hostapd.conf
interface=wlan1 #bridge=br0 driver=nl80211 logger_syslog=-1 logger_syslog_level=2 logger_stdout=-1 logger_stdout_level=2 ctrl_interface=/var/run/hostapd #ctrl_interface_group=wheel #ssid= country_code=US ieee80211d=1 ieee80211h=1 hw_mode=g channel=11 # acs_whitelist=1 2 3 4 5 6 7 8 9 10 11 ap_channel_sync=1 beacon_int=100 dtim_period=2 max_num_sta=10 supported_rates=10 20 55 110 60 90 120 180 240 360 480 540 basic_rates=10 20 55 110 60 120 240 preamble=1 macaddr_acl=0 #deny_mac_file=/etc/hostapd.deny auth_algs=3 ignore_broadcast_ssid=0 #vendor_elements=dd0411223301 tx_queue_data3_aifs=7 tx_queue_data3_cwmin=15 tx_queue_data3_cwmax=1023 tx_queue_data3_burst=0 tx_queue_data2_aifs=3 tx_queue_data2_cwmin=15 tx_queue_data2_cwmax=63 tx_queue_data2_burst=0 tx_queue_data1_aifs=1 tx_queue_data1_cwmin=7 tx_queue_data1_cwmax=15 tx_queue_data1_burst=3.0 tx_queue_data0_aifs=1 tx_queue_data0_cwmin=3 tx_queue_data0_cwmax=7 tx_queue_data0_burst=1.5 wme_enabled=1 uapsd_advertisement_enabled=1 wme_ac_bk_cwmin=4 wme_ac_bk_cwmax=10 wme_ac_bk_aifs=7 wme_ac_bk_txop_limit=0 wme_ac_bk_acm=0 wme_ac_be_aifs=3 wme_ac_be_cwmin=4 wme_ac_be_cwmax=10 wme_ac_be_txop_limit=0 wme_ac_be_acm=0 wme_ac_vi_aifs=2 wme_ac_vi_cwmin=3 wme_ac_vi_cwmax=4 wme_ac_vi_txop_limit=94 wme_ac_vi_acm=0 wme_ac_vo_aifs=2 wme_ac_vo_cwmin=2 wme_ac_vo_cwmax=3 wme_ac_vo_txop_limit=47 wme_ac_vo_acm=0 ap_max_inactivity=10000 disassoc_low_ack=1 ieee80211n=1 ht_capab=[SHORT-GI-20][GF] wep_rekey_period=0 eap_server=1 own_ip_addr=127.0.0.1 wpa=2 wpa_passphrase=snickerdoodle wpa_group_rekey=0 wpa_gmk_rekey=0 wpa_ptk_rekey=0 ap_table_max_size=255 ap_table_expiration_time=60 wps_state=2 ap_setup_locked=1 uuid=12345678-9abc-def0-1234-56789abcdef0 device_name=Sitara manufacturer=TexasInstruments model_name=TI_Connectivity_module model_number=wl18xx serial_number=12345 device_type=0-00000000-0 config_methods=virtual_display virtual_push_button keypad
DHCP Server
/etc/default/isc-dhcp-server
INTERFACES="wlan1"
Server Configuration
# # Configuration file for ISC dhcpd for Debian # ddns-update-style none; log-facility local7; subnet 10.0.110.0 netmask 255.255.255.0 { range 10.0.110.10 10.0.110.100; option routers 10.0.110.2; option broadcast-address 10.0.110.255; option domain-name "local"; default-lease-time 600; max-lease-time 7200; }