Difference between revisions of "Wlan"

From RobotinoWiki
(/etc/network/interfaces)
(/etc/udev/rules.d/99-wlan.rules)
Line 252: Line 252:
 
<pre>
 
<pre>
 
# USB device 0x:0x (rtl8187)
 
# USB device 0x:0x (rtl8187)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/sbin/ifup wlan0"
+
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/usr/bin/at -f /etc/init.d/start-wlan0-master.sh now",
 
SUBSYSTEM=="net", ACTION=="remove", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/sbin/ifdown wlan0"
 
SUBSYSTEM=="net", ACTION=="remove", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/sbin/ifdown wlan0"
 +
</pre>
 +
 +
===/etc/init.d/start-wlan0-master.sh===
 +
<pre>
 +
#!/bin/bash
 +
 +
LOG=/tmp/start-wlan0-master.log
 +
 +
echo "ifup wlan0" > $LOG
 +
/sbin/ifup wlan0
 +
 +
sleep 2
 +
 +
echo "start hostapd" >> $LOG
 +
/usr/sbin/hostapd -B /etc/hostapd.conf
 +
 +
sleep 2
 +
 +
echo "start dhcpd" >> $LOG
 +
dhcpd -pf /var/run/dhcp-server/dhcpd.pid wlan0
 +
 +
echo "Finished" >> $LOG
 
</pre>
 
</pre>
  

Revision as of 12:07, 12 September 2012

Robotino v1 and v2

Robotino up to version 2 is equipped with an internal access point. This internal AP can be configured as client or master.

Robotino v3

The next generation Robotino will use an USB WLAN stick to either connect to an access point in client mode or provide a access point external clients can connect to in master mode. Various WLAN USB adapters are supported. The following list shows the USB sticks tested to work in both client and master mode:

  • AVM Fritz!WLAN USB Stick N (support for a/b/g/n)

The following adapters are known to work at least in client mode:

  • Alfa AWUS036EW USB WLAN Stick (support for b/g)
  • Alfa AWUS036H USB WLAN (support for b/g)

hostapd configuration

The WLAN master on Robotino is run by hostapd. A german how-to on setting up a WLAN router using hostapd can be found here. Additionally a DHCP server is running assigning IP addresses to clients connecting to Robotino's access point.

/etc/default/hostapd

DAEMON_CONF="/etc/hostapd.conf"   # the configuration file to use
RUN_DAEMON=yes                    # start hostapd at system boot

/etc/hostapd.conf

interface=wlan0

# Driver interface type (hostap/wired/madwifi/test/none/nl80211/bsd);
# default: hostap). nl80211 is used with all Linux mac80211 drivers.
# Use driver=none if building hostapd as a standalone RADIUS server that does
# not control any wireless/wired driver.
driver=nl80211

# SSID to be used in IEEE 802.11 management frames
ssid=Robotino3AP

# Channel number (IEEE 802.11)
# (default: 0, i.e., not set)
# Please note that some drivers (e.g., madwifi) do not use this value from
# hostapd and the channel will need to be configuration separately with
# iwconfig.
channel=6

# visible ESSID
ignore_broadcast_ssid=0

# Country code (ISO/IEC 3166-1). Used to set regulatory domain.
# Set as needed to indicate country in which device is operating.
# This can limit available channels and transmit power.
country_code=DE

# Enable IEEE 802.11d. This advertises the country_code and the set of allowed
# channels and transmit power levels based on the regulatory limits. The
# country_code setting must be configured with the correct country for
# IEEE 802.11d functions.
# (default: 0 = disabled)
ieee80211d=1

# Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g,
# Default: IEEE 802.11b
hw_mode=g

# ieee80211n: Whether IEEE 802.11n (HT) is enabled
# 0 = disabled (default)
# 1 = enabled
# Note: You will also need to enable WMM for full HT functionality.
# ieee80211n=1

# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
beacon_int=100

# DTIM (delivery trafic information message) period (range 1..255):
# number of beacons between DTIMs (1 = every beacon includes DTIM element)
# (default: 2)
dtim_period=2

# Station MAC address -based authentication
# Please note that this kind of access control requires a driver that uses
# hostapd to take care of management frame processing and as such, this can be
# used with driver=hostap or driver=nl80211, but not with driver=madwifi.
# 0 = accept unless in deny list
# 1 = deny unless in accept list
# 2 = use external RADIUS server (accept/deny lists are searched first)
macaddr_acl=0

# Maximum number of stations allowed in station table. New stations will be
# rejected after the station table is full. IEEE 802.11 has a limit of 2007
# different association IDs, so this number should not be larger than that.
# (default: 2007)
max_num_sta=255

# RTS/CTS threshold; 2347 = disabled (default); range 0..2347
# If this field is not included in hostapd.conf, hostapd will not control
# RTS threshold and 'iwconfig wlan# rts <val>' can be used to set it.
rts_threshold=2347

# Fragmentation threshold; 2346 = disabled (default); range 256..2346
# If this field is not included in hostapd.conf, hostapd will not control
# fragmentation threshold and 'iwconfig wlan# frag <val>' can be used to set
# it.
fragm_threshold=2346

# hostapd event logger configuration
#
# Two output method: syslog and stdout (only usable if not forking to
# background).
#
# Module bitfield (ORed bitfield of modules that will be logged; -1 = all
# modules):
# bit 0 (1) = IEEE 802.11
# bit 1 (2) = IEEE 802.1X
# bit 2 (4) = RADIUS
# bit 3 (8) = WPA
# bit 4 (16) = driver interface
# bit 5 (32) = IAPP
# bit 6 (64) = MLME
#
# Levels (minimum value for logged events):
#  0 = verbose debugging
#  1 = debugging
#  2 = informational messages
#  3 = notification
#  4 = warning
#
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2

# Dump file for state information (on SIGUSR1)
dump_file=/tmp/hostapd.dump

# Interface for separate control program. If this is specified, hostapd
# will create this directory and a UNIX domain socket for listening to requests
# from external programs (CLI/GUI, etc.) for status information and
# configuration. The socket file will be named based on the interface name, so
# multiple hostapd processes/interfaces can be run at the same time if more
# than one interface is used.
# /var/run/hostapd is the recommended directory for sockets and by default,
# hostapd_cli will use it when trying to connect with hostapd.
ctrl_interface=/var/run/hostapd

# Access control for the control interface can be configured by setting the
# directory to allow only members of a group to use sockets. This way, it is
# possible to run hostapd as root (since it needs to change network
# configuration and open raw sockets) and still allow GUI/CLI components to be
# run as non-root users. However, since the control interface can be used to
# change the network configuration, this access needs to be protected in many
# cases. By default, hostapd is configured to use gid 0 (root). If you
# want to allow non-root users to use the contron interface, add a new group
# and change this value to match with that group. Add users that should have
# control interface access to this group.
#
# This variable can be a group name or gid.
#ctrl_interface_group=wheel
ctrl_interface_group=0

# IEEE 802.11 specifies two authentication algorithms. hostapd can be
# configured to allow both of these or only one. Open system authentication
# should be used with IEEE 802.1X.
# Bit fields of allowed authentication algorithms:
# bit 0 = Open System Authentication
# bit 1 = Shared Key Authentication (requires WEP) 
auth_algs=3

# Default WMM parameters (IEEE 802.11 draft; 11-03-0504-03-000e):
# for 802.11a or 802.11g networks
# These parameters are sent to WMM clients when they associate.
# The parameters will be used by WMM clients for frames transmitted to the
# access point.
#
# note - txop_limit is in units of 32microseconds
# note - acm is admission control mandatory flag. 0 = admission control not
# required, 1 = mandatory
# note - here cwMin and cmMax are in exponent form. the actual cw value used
# will be (2^n)-1 where n is the value given here
#
wmm_enabled=0

# Enable WPA. Setting this variable configures the AP to require WPA (either
# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either
# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.
# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),
# RADIUS authentication server must be configured, and WPA-EAP must be included
# in wpa_key_mgmt.
# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
# and/or WPA2 (full IEEE 802.11i/RSN):
# bit0 = WPA
# bit1 = IEEE 802.11i/RSN (WPA2) (dot11RSNAEnabled)
wpa=2

# Enable IEEE 802.11i/RSN/WPA2 pre-authentication. This is used to speed up
# roaming be pre-authenticating IEEE 802.1X/EAP part of the full RSN
# authentication and key handshake before actually associating with a new AP.
# (dot11RSNAPreauthenticationEnabled)
rsn_preauth=1

# Space separated list of interfaces from which pre-authentication frames are
# accepted (e.g., 'eth0' or 'eth0 wlan0wds0'. This list should include all
# interface that are used for connections to other APs. This could include
# wired interfaces and WDS links. The normal wireless data interface towards
# associated stations (e.g., wlan0) should not be added, since
# pre-authentication is only used with APs other than the currently associated
# one.
rsn_preauth_interfaces=wlan0

# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The
# entries are separated with a space. WPA-PSK-SHA256 and WPA-EAP-SHA256 can be
# added to enable SHA256-based stronger algorithms.
# (dot11RSNAConfigAuthenticationSuitesTable)
wpa_key_mgmt=WPA-PSK

# Set of accepted cipher suites (encryption algorithms) for pairwise keys
# (unicast packets). This is a space separated list of algorithms:
# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
# Group cipher suite (encryption algorithm for broadcast and multicast frames)
# is automatically selected based on this configuration. If only CCMP is
# allowed as the pairwise cipher, group cipher will also be CCMP. Otherwise,
# TKIP will be used as the group cipher.
# (dot11RSNAConfigPairwiseCiphersTable)
# Pairwise cipher for WPA (v1) (default: TKIP)
#wpa_pairwise=TKIP CCMP
# Pairwise cipher for RSN/WPA2 (default: use wpa_pairwise value)
rsn_pairwise=CCMP

# Time interval for rekeying GTK (broadcast/multicast encryption keys) in
# seconds. (dot11RSNAConfigGroupRekeyTime)
wpa_group_rekey=600
wpa_ptk_rekey=600
wpa_gmk_rekey=86400

# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit
# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase
# (8..63 characters) that will be converted to PSK. This conversion uses SSID
# so the PSK changes when ASCII passphrase is used and the SSID is changed.
# wpa_psk (dot11RSNAConfigPSKValue)
# wpa_passphrase (dot11RSNAConfigPSKPassPhrase)
wpa_passphrase=robotino3ap

/etc/network/interfaces

  1. auto wlan0

iface wlan0 inet static

 address 172.26.1.1
 netmask 255.255.0.0
 #wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
 post-up /usr/sbin/hostapd -B /etc/hostapd.conf
 post-up dhcpd -pf /var/run/dhcp-server/dhcpd.pid wlan0
 post-down killall dhcpd
 post-down killall hostapd

/etc/udev/rules.d/99-wlan.rules

# USB device 0x:0x (rtl8187)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/usr/bin/at -f /etc/init.d/start-wlan0-master.sh now",
SUBSYSTEM=="net", ACTION=="remove", DRIVERS=="?*", KERNEL=="wlan0", RUN+="/sbin/ifdown wlan0"

/etc/init.d/start-wlan0-master.sh

#!/bin/bash

LOG=/tmp/start-wlan0-master.log

echo "ifup wlan0" > $LOG
/sbin/ifup wlan0

sleep 2

echo "start hostapd" >> $LOG
/usr/sbin/hostapd -B /etc/hostapd.conf

sleep 2

echo "start dhcpd" >> $LOG
dhcpd -pf /var/run/dhcp-server/dhcpd.pid wlan0

echo "Finished" >> $LOG

/lib/udev/rules.d/75-cd-aliases-generator.rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="057c", ATTRS{idProduct}=="84ff", ACTION=="add", OPTIONS+="ignore_device", GOTO="persistent_cd_end"

/lib/udev/rules.d/60-persistent-storage.rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="057c", ATTRS{idProduct}=="84ff", ACTION=="add", OPTIONS+="ignore_device", GOTO="persistent_storage_end"