The wireless interface (most commonly <tt>wlan0</tt>) can be brought up with:

+

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:

+

+

<pre>

+

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

+

</pre>

+

+

+

=== Bringing up Wireless Interface ===

+

+

The wireless interface (most commonly <tt>wlan0</tt>) can be brought up manually with:

<pre>

<pre>

Line 137:

Line 153:

−

== Network Interface Configuration ==

+

=== Network Interface Configuration ===

Files defining the network configuration information can be created within the <tt>/etc/network/interfaces.d</tt> directory which is sourced when <code>ifup -a</code> is run (typically from within the network boot script sourced from <tt>/etc/init.d/networking</tt>). The following example brings up the interface on boot up by identifying the inteface with <code>auto wlan0</code>. The rules defined after <code>iface wlan0 inet manual</code> 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 <tt>/etc/wpa_supplicant.conf</tt>.

Files defining the network configuration information can be created within the <tt>/etc/network/interfaces.d</tt> directory which is sourced when <code>ifup -a</code> is run (typically from within the network boot script sourced from <tt>/etc/init.d/networking</tt>). The following example brings up the interface on boot up by identifying the inteface with <code>auto wlan0</code>. The rules defined after <code>iface wlan0 inet manual</code> 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 <tt>/etc/wpa_supplicant.conf</tt>.

Line 152:

Line 168:

The combination of files within <tt>/etc/network/interfaces.d</tt> and the [[#Wireless Naming Rules|<tt>/etc/udev/rules.d/70-persistent-net.rules</tt>]] create the rules for naming and controlling the bring-up/down of the network interfaces.

The combination of files within <tt>/etc/network/interfaces.d</tt> and the [[#Wireless Naming Rules|<tt>/etc/udev/rules.d/70-persistent-net.rules</tt>]] create the rules for naming and controlling the bring-up/down of the network interfaces.

+

+

== Wireless Access Point ==

+

+

=== Network Interface Configuration ===

+

+

<pre>

+

auto wlan1

+

+

iface wlan1 inet static

+

address 10.0.110.2

+

netmask 255.255.255.0

+

hostapd /etc/hostapd.conf

+

</pre>

+

+

=== 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 <code>hostapd</code> 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.

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:

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:

Checking Internet Connection (ping)

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.

Wireless Access Point

Network Interface Configuration

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.