Aug 292013
 

Debian unfortunately has pv in an older version, the newest one includes a very practical “-S” option, which will stop at a certain size (which is specified by –s in bytes).

I use it to calculate checksums of SD cards (Raspberry Pi images!). Now some SD cards are larger than others, but still the same image size is written.

Fortunately, we can combine several Linux tools to still get a predictable MD5 sum of a fixed size of the input file / SD card:

pv -tprebc -B 512K -s 7742685184 /dev/sdn | head -qc 7742685184 | md5sum

pv: Pipe Viewer, will show a progress bar

  • t – turn the timer on – will show the total time pv has been running
  • p – show progress bar
  • r – turn the rate counter on – will show the data transfer rate
  • e – show estimated time of arrival
  • b – turn total byte counter on
  • c – cursor mode (do not use carriage returns). May be handy when displaying multiple pv’s on the screen?
  • B – Buffer size
  • s <bytes> – assume file is <bytes> big, when calculating the percentages and ETAs
  • S – stop after s <bytes> have been read (NOT available in the Debian version currently)

head: show only the first bytes of a file

  • q – quiet: don’t show the file name
  • c <bytes> – read <bytes> from the beginning of the file (otherwise head will assume you mean lines)

md5sum: calculate the md5sum of a file

Bonus:

du –b <filename> 

will show the size of a file in bytes

blockdev --getsize64 /dev/sdb

will show the size of /dev/sdb (for instance a USB card reader with a SD card inserted) in bytes.

Aug 272013
 

CUPS_printer

Prerequisites

ALL of the following commands will be run as root. If you are not root already, you can become root by entering “sudo su” as user pi.

Install packages

aptitude update
aptitude install avahi-daemon cups cups-pdf python-cups
  • This will update your package list, and install the packages we need
  • avahi-daemon is a free zeroconf implementation (open source Bonjour replacement)
  • CUPS = Common Unix Printing System – manages the printers for you

This command will take a while, especially after [ ok ] Starting Common Unix Printing System: cupsd. Please be patient here.

Edit /etc/cups/cupsd.conf

nano /etc/cups/cupsd.conf

Comment out the line just below “# Only listen for connections from the local machine.” with an #, and add some new lines, like this:

# Only listen for connections from the local machine.
#Listen localhost:631
#CHANGED TO LISTEN TO LOCAL LAN
Port 631
# Restrict access to the server...
<Location />
  Order allow,deny
  Allow @Local
</Location>
 
# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow @Local
</Location>
 
# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @Local
</Location>

Leave the other lines as they are.

  • This will allow access to the CUPS web interface from other machines than your Raspberry Pi itself (on the local network)
  • We advise you to change the default “raspberry” password for the user “pi” just in case …
  • You can change the port from 631 to something else, but be sure to replace it in the instructions below!

Restart the CUPS service

service cups restart
  • This will restart the CUPS service and reload it’s configuration files

Add the user pi to the lpadmin group

This is necessary to allow you to administrate the printers through the web interface as user pi, later on:

adduser pi lpadmin

AirPrint will have to be enabled after you have added the printers.

 

Add printer(s)

CUPS actually has a very nice web-interface. It apparently has been purchased by Apple in 2007, and is being supported by that huge company and the original developer, Michael Sweet. Maybe that is one reason why it really works quite effortlessly. But, let’s begin:

Open your favorite browser, and enter “https://” + your Raspberry Pi’s IP address + “:” + the port (631 as default).

For example: https://192.168.1.11:631/

CUPS Admin interface

Your browser will most definitely warn you about a security certificate problem. Please ignore it, and continue (or do you sign certificates for your local machines?)

CUPS-interface-raspberry-pi

Hint: CUPS will show up to you in the language your browser indicates to it. Even the directive “DefaultLanguage en” in the configuration file will NOT change that. In other words, to change the language of the CUPS web interface, change your browser default language setting.

Modify CUPS Settings

Click on the Administration Tab, and check “Share printers connected to this system”. Click on “Change Settings”.

cups-administration-tab

At this point you will probably be asked to enter your credentials. If you have added the user pi to the printer management group lpadmin, as per instructions above, you can enter it’s credentials now:

credentials-required

The CUPS server is being restarted.

Connect Printer to CUPS

You can add network printers, or USB printers to CUPS.

Before continuing with the instructions, please ensure that your printer is connected to the network or via USB to the Raspberry Pi , and powered on. You do not need to restart your Raspberry – you can simply plug in your printer right now.

Add a new printer to CUPS

If you have a USB printer, click on “Find New Printers” on the Administration tab (this is called “Verfügbare Drucker auflisten” in German)

cups-find-new-printers

CUPS will take a while – and it should list all printers which it has recognized.

add-kyocera-fs3900dn-cups

Simply add the printer, in this example my trusty Kyocera FS-3900DN (I will only buy Kyocera Laser printers from now on Winking smile). My DYMO LabelWriter 450 was also recognized “out-of-the-box”.

Now simply follow the dialogues and enter sensible values:

add-printer-step-2-example

 

cups-add-printer-iii

(Note: the connection line in the screenshot will say something like “usb://…” for USB printers).

Select your Make and your Model here. A lot of printers are listed. If you don’t find yours, try to find a PPD file for it on the web: A PPD File is a “PostScript Printer Description”” File – it describes fonts, paper sizes, resolutions and other capabilites that are standard for a particular Postscript printer.

Now you will be presented with a dialogue which will have different default options to set up, according to your printer.

Here’s the one for the Kyocera FS-3900DN, for example:

kyocera-fs-3900dn-cups-default-options

Please note: these are default options. If, for instance, the paper sizes your printer supports are not listed here (as is the case for my DYMO LabelWriter 450), simply select the next “matching” one, and set it up under Windows / your Mac correctly.

Now your printer is set up, and you can continue:

Print test page

The CUPS menu “Printers” will list the available printers. By clicking on a particular printer, you can administrate it. For instance, you can print a test page from the Maintenance drop down menu:

cups-test-job

CUPS will show you the progress of the print job.

Adding network printers to CUPS

If you have a network printer, we recommend to use the “Add Printer” button instead, and setting up the printer manually.

appsocket

The CUPS manual recommends to use “HP JetDirect” as it is the most reliable protocol. This works with my Kyocera FS-3900DN.

cups-socket

In the next screen, enter your printer’s IP address, followed by the port (i.e. socket://192.168.1.21:9100 ). There are options to set up secure (encrypted) printing, but this is beyond the scope of this article.

Now you can continue as described above.

Set up AirPrint

In GitHub, there is a script which creates the AirPrint service. In the German article this one translates and elaborates, it is recommended to put it into /opt/AirPrint.

As user root (sudo su):

mkdir /opt/AirPrint
cd /opt/AirPrint
wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
chmod +x airprint-generate.py
./airprint-generate.py -d /etc/avahi/services
service cups restart
service avahi-daemon restart

This will:

  • Create a new directory “/opt/AirPrint”, change into it
  • Download the airprint-generate.py script
  • make it executable
  • execute it, and modify the configuration files in the directory /etc/avahi/services (add an XML description of the new printer service)
  • restart the CUPS and avahi services

If the ./airprint-generate.py command yields an error, like “image/urf is not in mime types, [PRINTER_NAME] may not be available on ios6 (see https://github.com/tjfontaine/airprint-generate/issues/5)”, please refer to the solution in the German article (there is always Google Translate)

The printers should be available now.

 

Install printer on Windows

Open “Devices and Printers”. Click “Add a printer”. Select “Add a network, wireless or Bluetooth printer”.

image

Select “The printer that I want isn’t listed”

image 

image

Select “Select a shared printer by name”, and enter http:// + Raspberry Pi IP + :631 + /printers/ + your printer’s name (called “Queue Name” in CUPS).

For example: http://192.168.1.11:631/printers/kyo-3900

Again, this could probably be changed for encryption – but is outside the scope of this beginner’s article.

Click “Next”, and continue to install the driver. If you can’t select it from the list, try Windows Update (be patient). If that does not work, try to locate the driver on the vendor’s homepage. I had to do the latter for the DYMO LabelWriter 450.

Remember to set up sensible default settings for your new network printer. These settings will override the settings you set on CUPS – thus you CAN actually print to page formats CUPS does not know yet.

 

Add printer to Apple Mac

This Apple KB article should help you to set up your printer on your Mac. Unfortunately there’s no Mac here, when we have access to one, we will test it.

 

 

Problem solving

Can’t find a network printer

Try to add it manually, by using it’s IP address and the information we have given you in this article. If it still does not work, try changing your printer LAN server settings.

Well, what about SAMBA?

CUPS printers can be shared through SAMBA. This is additional configuration overhead, but may add the possibility for Windows machines to automatically download drivers from the Raspberry Pi. This is beyond the scope of this article.

References

Jul 232013
 

Update

We have released dfreerdp (FreeRDP for the DirectFB backend) as a package for the Raspberry Pi. Please go to our new blog post to get it!

Intro

RDP is a convenient way to connect to Windows and also other operating systems with RDP host software, e.g. Linux. RDP transmits display information more efficiently than VLC, as it sees the structure of the screen and it’s elements. It also allows to transmit audio information both ways – playback and recording, share printers, drives, and more. As it is an extensible protocol, efficient video / multimedia playback can be implemented – and has been implemented, albeit apparently only in Windows Media Player.

The Raspberry Pi is a low-power device, with Full-HD (and audio) capable HDMI output.

FreeRDP is a mighty utility to connect to RDP servers, and utilize many of their possibilities. It even supports the video extensions for RDP (in RDP lingo: video redirection virtual channel extension) with ffmpeg. Don’t get your hope up too high right now, though: while theoretically feasible in software, it still would have to be written for both the Raspberry AND the host (it is not a “plug & forget” solution, but the software run on the server has to support it specifically).

The current state: A marriage made in heaven?

Not quite. FreeRDP is easily installed, and used from an X session. But it is … agonizingly slow. Audio playback is in a bad state.

The problem: X adds a very high overhead to any application, but even more so a graphics intensive, such as FreeRDP. Even super-charging the Raspberry Pi with overclocking, Class 10 SD cards, a beefy power supply, etc. will NOT solve this problem! An RDP client compiled specifically for Wayland might, but this is still some way off.

Solution

FreeRDP can be compiled to draw to the Direct Frame Buffer. This eliminates all of the overhead, which X would add. This is perfect for people really trying to use the Raspberry as Windows / RDP thin client. It will work in FullHD resolution (over the local network), with sufficient performance (and 16 bit color depth).

Kudos are in order to the Tao of Mac blog, which had the idea, and the instructions to get me up and running. You rock!

We will release a hardware & software package RDP client, based on the Raspberry, really soon now. If you’re interested, hit me up in the comments.

Step-by step instructions

With all that out of the way, let’s jump into the instructions!

Preparation

We suggest to use a Class 10 SD card, with ample space for the installation & build of the packages (8 GB Class 10 seems sensible). Install the newest Raspbian image, set up your locale and keyboard layout, aptitude update and aptitude upgrade.

Install the necessary packages:

aptitude install build-essential git-core cmake libssl-dev libx11-dev libxext-dev libxinerama-dev libxcursor-dev libxdamage-dev libxv-dev libxkbfile-dev libasound2-dev libcups2-dev libxml2 libxml2-dev libxrandr-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libavutil-dev libavcodec-dev libcunit1-dev libdirectfb-dev xmlto doxygen libxtst-dev

This should take quite a while.

Download the FreeRDP package (use a sensible location, we will be compiling there later. If in doubt, a sub-folder in your home folder is OK):

wget https://github.com/FreeRDP/FreeRDP/archive/1.0.2.tar.gz

You might also consider checking out the 1.0.3 pre-release version. It might turn stable in a couple of months.

Set up the build environment – this is analoguous to ./configure seen in many other compilations:

cmake -DCMAKE_BUILD_TYPE=Release  -DWITH_FFMPEG=OFF -DWITH_XINERAMA=OFF -DWITH_XCURSOR=OFF -DWITH_DIRECTFB=ON -DCMAKE_INSTALL_PREFIX=~/freerdp

A couple of hints for this:

  • You might want to adjust the –DCMAKE_INSTALL_PREFIX to something more suitable – if you compile as root, it will install the application and the libraries into the folder /root/freerdp otherwise.
    A good choice could be /usr – this way the binaries and libraries will be in the normal search path.
  • turning off FFMPEG means turning off virtual video extension. As discussed before, this is of limited use anyway, right now. But some experimenting might be interesting. FreeRDP also is built modularized on top of FFMPEG, so exchanging that for an omxplayer-like code thingy SHOULD be feasible.
  • Xinerama – is an X extension which allows X applications to span two or more displays a one large virtual display.

Check for the output of this command. It will tell you about skipped options and missed packages. It should find DirectFB amongst others (Found DirectFB: /usr/lib/arm-linux-gnueabihf/libdirectfb.so).

  • pulseaudio: this is a sound server, and another layer on ALSA. It is network capable. Users report varying mileage with pulseaudio and good playback quality. We have tested without the pulseaudio package, future tests will show whether there is an advantage in using it.
  • pcsc – this is for smart card support, most likely you will not need it
  • CUnit – a lightweight system for writing, administering and running unit tests in C – most likely you will not need this, either.

Compile the DirectFB RDP client:

cd client/DirectFB/
make

#optionally 
sudo make install

#for sound support
cd ../../channels/drdynvc
make
sudo make install
cd ../rdpsnd
make
sudo make install

This is all – but this will take quite a while (some hours).

Set up some configuration files

Edit your /etc/udev/rules.d/99-input.rules to be:

SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="tty[0-9]*", GROUP="root", MODE="0666"
KERNEL=="mice", MODE="0666"
KERNEL=="fb0", OWNER="root", MODE="0660"

The first line should aready be in the file, add the other three lines.

Optional, but recommended: Edit your /boot/config.txt to contain the following settings:

framebuffer_width=1920
framebuffer_height=1080
framebuffer_depth=16
# for other stuff
gpu_mem=128

arm_freq=800
disable_overscan=1
hdmi_drive=2
hdmi_ignore_edid=0xa5000080

This will

  • set your resolution as fixed [framebuffer_width, framebuffer_height] – be sure to adjust to your needs!
  • set bit depth to 16 – as we will connect to the RDP server using this depth for better performance.
  • ignore anything the monitor will tell the Raspberry – it might lead to blurry edges, otherwise [hdmi_ignore_edid=0xa5000080]
  • overclock the raspberry just a little [arm_freq=800]
  • disable the overscan – remove the black area around the display output on modern LCD monitors [disable_overscan=1]
  • set up the HDMI output to be a real HDMI output and carry audio – this will fix “no sound output” problems [hdmi_drive=2] don’t use this if you connect your Raspberry via DVI or VGA to the monitor

Edit /etc/fb.modes and add a new mode:

# Added as per taoofmac instructions
mode "1920x1080-24p"
   geometry 1920 1080 1920 1080 32
   timings 13468 148 638 36 4 44 5
endmode

You will have to adjust this if you use a different resolution than FullHD. The original article at Tao of Mac has some more resolution examples for you.

Create a new file /etc/directfbrc with the following contents:

system=fbdev
autoflip-window
desktop-buffer-mode=auto
vt-switching
graphics-vt
no-deinit-check
no-motion-compression
no-translucent-windows
memcpy=arm
mode=1920x1080
depth=16
dma
hardware
# for the moment, we need DirectFB's own cursor sprite
cursor

Reboot.

 

Usage

If you specified –DCMAKE_INSTALL_PREFIX to be /usr, you should be able to use FreeRDP DirectFB client without any path prefix, else just prepend your path:

dfreerdp -u "user name" -p secret_password_here -f -g 1920x1080 -x l -z --disable-full-window-drag  --gdi hw --plugin rdpsnd --data alsa --  host:port

Be sure to adjust this command:

  • “user name” should be your user name. If it contains a space, you should keep the quotation marks, else you can loose them.
  • secret_password_here should be your password, obviosly.
  • -g specifies the geometry. Adjust, as necessary.
  • -x = experience (l for LAN), will enable different bells and whistles. You might want to modify that, or use a more finegrained control of which features to enable, and which to disable
  • -z enable compression (useful)
  • –gdi hw – I’m not sure whether this is really necessary
  • –plugin rdpsnd –data alsa —  – this will enable remote sound output on the Raspberry. Drdynvc is said to have better quality, but I could not get it to work unfortunately. And, yes, the trailing double dashes are part of this option.
  • server:port – can be specified as domain or IP adress. The :port can be omitted, if you are connecting to the default RDP port (3389)

If you want sound output on the remote machine, use the –o switch.

 

FAQ

What about keyboard layout?

It will work exactly as you see your keyboard input on the Raspberry console itself. Even the Windows key should work. If your layout does not work on the Raspberry console, consider setting it up using raspi-config

Will this work over WLAN?

Sure it will. Just adjust your WiFi dongle for optimum throughput and latency (yes, literally change its position, tilt, etc. until you find the best performance spot!)

We recommend you the following packes for graphical / console adjustment of Wireless settings:

aptitude install wicd wicd-gtk wicd-curses

Will Skype work?

Not tested yet – enlighten us Smile This will need microphone redirection, too.

Will forwarding of devices work?

Not tested yet – inform us about usb printers, thumb drives, etc.

How can I test sound output on the Raspberry?

aplay /usr/share/scratch/Media/Sounds/Vocals/Singer2.wav -v -V mono

Will performance over WAN networks be OK?

Yes, pretty much – sound output will suffer (a lot), but the GUI will still be quite usable. You might want to adjust the flags to disable some eye candy.

Why do the browsers “stutter” during scrolling?

In my understanding: Unfortunately browsers need a very high degree of control over their screen outputs, and thus they render it themselves, instead of letting Windows do it – RDP sees browser output as image, which is retransmitted when scrolling. Playing with image compression options might alleviate this problem a bit.

Will accessing Linux hosts over RDP work?

Not out of the box – you will need to install an X to RDP conversion software.

In a very quick and rough test, a connection set up by the Scarygliders X11 RDP O Matic as a server backend did not work reliably enough (it was installed on a Pentium IV Linux server). It might do so with some tuning.

Or another backend / solution might do the trick. Looking forward to your input Smile

 

Known problems

  • Flash (isn’t it always on some list?) – will deliver horrible audio performance, native players (Foobar2000) will be OK, though.
  • Video playback – don’t even dream of playing YouTube videos over an RDP connection … the time is not ready yet, the software not written. Care to join a noble cause?
  • WLAN performance will depend on WLAN throughput and latency. The orientation of your dongle – especially nano dongles – will be very important. It can be tuned to a decent performance state, though.
  • I can’t get the new / style switches to work with FreeRDP, fallback to the legacy – switches for now.
  • Sound output: only rdpsnd works, –plugin drdynvc –data tsmf:audio:alsa:plughw:0,0 — will not work – maybe this is a configuration issue, though and some other parameters need to be passed. Drdynvc is said to have better quality. The issue might be with servers with no sound card drivers installed. I did not find an easy solution to this, and I am looking forward to your suggestions.
  • Connection to Linux RDP server compiled with X11 RDP O Matic is not stable for me.

References & further reading

Jul 232013
 

Hintergrund

Auf dem Raspberry Pi befindet sich “von Werk aus” kein grafischer Netzwerk-Manager. Es ist also die Kommandozeile gefragt, was manchmal unbequem, lästig oder mit Fehlern verbunden sein kann.

Wir stellen in diesem Artikel daher kurz vor, wie man unter Raspbian mit Wicd einen grafischen Netzwerk-Manager aktiviert.

Installation

Öffnen Sie LXTerminal und installieren Sie die benötigten Pakete:

sudo aptitude update
sudo aptitude install wicd wicd-gtk wicd-curses

Nutzung

Nach Neustart von X erscheint in Ihrer Notification Area rechts unten ein neues Icon. Durch Klick auf dieses Icon können Sie sowohl LAN, als auch WLAN Netzwerke mit einer Vielzahl von Möglichkeiten verwalten.

Wicd-Icon

Durch Rechtsklick auf das Icon, und Auswahl von “Connection Info” kann man seine aktuelle IP Adresse herausfinden:

wicd-show-ipadress

Alternativ kann Wicd auch aus dem Menü gestartet werden:

Wicd-start

Wicd zeigt die verfügbaren Funknetzwerke an:

wicd-manager

Durck Klick auf “Connect” kann man sich zu einem Netzwerk verbinden. Falls es eine Passwort-Eingabe erfordert, weist Wicd den Nutzer darauf hin, und öffnet den “Properties” Dialog.

Für die meisten Netzwerke wird es hier nur erforderlich sein, den Preshared Key einzugeben. Wählen Sie aus dem Menü “WPA 1/2 (Passphrase)”, und geben Sie Ihren Preshared key ein.

wpa-properties-dialogue

Nach Klick auf OK drücken Sie erneut “Connect” um sich mit dem Funknetzwerk zu verbinden. Der Erfolg wird in der Statuszeile unten angezeigt:

wicd-connected

WLAN Konfiguration unter der Konsole

Mit Wicd kann man die Funknetzwerkeinstellungen auch unter der Konsole – ohne X Session – verwalten. Geben Sie dazu einfach ein:

sudo wicd-curses

wicd-curses

wicd-curses wird mit der Tastatur bedient. Das Menü unten zeigt die möglichen Eingaben an.

Mit Pfeiltaste nach rechts wird der aktuell ausgewählte Eintrag bearbeitet. Hier kann man die IP Einstellungen, die DNS Einstellungen und den Preshared Key eingeben. Außerdem kann festgelegt werden, dass eine Verbindung zu diesem Netzwerk automatisch hergestellt werden soll. Mit F10 bestätigt man die Einstellungen. Anschließend kann man Q drücken, um wicd-curses zu verlassen.

Weiterführende Informationen & Quellen

Jun 172013
 

Intro

wifi_logo (1)In diesem Artikel stelle ich eine Lösung vor, um  das Netzwerk an dem der Raspberry verbunden ist über einen USB WLAN Adapter für andere Computer zur Verfügung zu stellen. Der Raspberry arbeitet dabei als Brücke (bridge), und leitet einfach alle Daten die am WiFi  Adapter ankommen in das LAN weiter.

Das kann bspw. sinnvoll sein, wenn man zwei Netzwerke zu Hause betreiben möchte – ein schnelles für n-fähige Geräte, und ein langsames für b / g Geräte; Eine Isolation der Netzwerke gegeneinander findet aufgrund des bridged Modes in unserer Anleitung nicht statt – die IP Adressen der über WLAN angeschlossenen Computer z..B. werden vom  DHCP-Router vergeben, nicht vom Raspberry.

Ein weiterer Einsatzzweck ist das Einrichten von WLANs in anderen Stockwerken / entfernten Orten (z.B. im Keller?), vor allem wenn man  dem  Raspberry noch weitere Aufgaben angedeihen lassen möchte.

Der Vorteil an der bridged Lösung ist geringerer Prozessor-Overhead für den Raspberry, und geringerer Verwaltungsaufwand (IP Adressen).

Hardware-Anforderungen

Nicht alle USB WLAN Sticks unterstützen den dazu notwendigen AP Modus, bzw. die “nl80211 API”. Wir beschreiben weiter unten, wie Sie Ihren Stick überprüfen können.

cartIn unserem Shop bieten wir den Logilink WL0084B v2.0 an, der als Access Point geeignet ist.

Er basiert auf dem Ralink RT5370 Chipsatz.

 

Root-Rechte nötig

Die folgenden Kommandos sind alle als root Nutzer auszuführen (sudo su).

Installation der nötigen Pakete
aptitude install hostapd hostap-utils iw bridge-utils
  • hostapd, hostap-utils: WLAN Stick als Access Point nutzen
  • iw: Konfigurations-Programm für Funknetzwerk-Devices
  • bridge-utils: ermöglichen zwei Netzwerke miteinander zu verbinden

iw hilft festzustellen ob Ihr USB-WiFi Stick Access-Point fähig ist. Nicht alle sind es!

iw list

iw list zeigt die vorhandenen Funknetzwerk-Geräte an.

nl80211 not found

Falls hier der Fehler “nl80211 not found” auftaucht, wird eine ältere Version von hostapd benötigt. Weitere Details dazu – bspw. für den TP-Link TL-WN725N WiFi – gibt es auf dieser Seite. Der besagte TP-Link wäre bei lsusb beispielsweise folgendermaßen aufgeführt (v1):

Bus 001 Device 011: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Sticks die die nl80211 API unterstützen

Wir benutzen im folgenden einen USB-WLAN Stick, der die nl80211 api unterstützt, d.h. dieser Fehler taucht NICHT auf, sondern man erhält mit iw list etwa folgende Ausgabe:

root@andromeda:~# iw list
Wiphy phy9
        Band 1:
( ... )
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * WDS
                 * monitor
                 * mesh point
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor
        interface combinations are not supported
( ... )        
Device supports HT-IBSS.

Wir nutzen einen Logilink Adapter (Modell WL0084B v2.0), per lsusb wird dessen Chipsatz identifiziert als:

Bus 001 Device 021: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

 

Konfiguration

Zunächst muss man in der /etc/init.d/hostapd den Pfad zur (noch zu erstellenden) hostapd Konfigurationsdatei einstellen. ( nano /etc/init.d/hostapd ) Finden Sie die Zeile mit DAEMON_CONF, und ergänzen Sie sie wie folgt:

DAEMON_CONF=/etc/hostapd/hostapd.conf

erstellen Sie jetzt die hostapd.conf ( nano /etc/hostapd/hostapd.conf ) und befüllen Sie sie mit dem folgenden Inhalt:

ctrl_interface=/var/run/hostapd
###############################
# Basic Config
###############################
macaddr_acl=0
auth_algs=1
# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211
##########################
# Local configuration...
##########################
interface=wlan0
bridge=br0
hw_mode=g
channel=1
ssid=www.pi3g.com
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=BITTE___AENDERN
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Kurze Diskussion der Datei /etc/hostapd/hostapd.conf

hostapd.conf ist empfindlich was Leerzeichen hinter den jeweiligen Konfigurationseinstellungen angeht – bitte vermeiden Sie diese daher.

  • driver: nl80211 bei Geräten die die nl80211 API unterstützen. Es sind auch andere (legacy-) APIs verfügbar, siehe hier
  • interface: man kann auch mehrere WiFi Adapter am Raspberry anschließen – der erste heißt wlan0
  • bridge: diese Brücke werden wir gleich noch einrichten
  • hw_mode: Verbindungsmodus. g bedeutet: g + b
    • b bedeutet: nur b
  • SSID: die SSID des Hotspots
  • wpa=3: WPA1 und WPA2 werden enabled – diese sind dem unsicheren WEP vorzuziehen
  • wpa_passphrase: das ist Ihr Netzwerkschlüssel. BITTE ÄNDERN SIE DIESEN!!

Um 802.11 n einzuschalten, muss man einen zusätzlichen Parameter “ieee80211n” auf 1 setzen. z.B. für g & n:

hw_mode=g
ieee80211n=1
 
Konfiguration der bridge

Die Bridge sorgt dafür, dass die Netzwerkpakete die die Access Point Clients über diesen senden direkt über den Ethernet Port des Raspberrys weitergeleitet werden. Wir haben die bridge-utils bereits installiert, und müssen nur noch die Einstellungen anpassen.

Editieren Sie die /etc/network/interfaces (nano etc/network/interfaces )

auto lo

iface lo inet loopback
auto br0
iface br0 inet static
        address 192.168.1.11
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        bridge-ports eth0 wlan0

Kurze Diskussion:

  • Die bridge br0  ersetzt Ihr bisheriges eth0 Interface, sie wird daher wie eth0 konfiguriert
    • hier in einer statischen Konfiguration – unser Netzwerk ist 192.168.1.*, der Router 192.168.1.1
  • bridge-ports eth0 wlan0 ist das “magische Kommando”, was wlan0 mit eth0 verknüpft
  • Das ist alles – keine weiteren Einträge (insbesondere nicht für wlan0)

Neustart

Nach einem Neustart sollte das System voll funktionsfähig sein. Sie können jetzt Clients mit Hilfe der Zugangsdaten über den Access Point verbinden.

Alternativ können Sie es auch mit folgenden Kommandos ohne Neustart versuchen:

ifdown eth0; ifup br0
service hostapd restart
DNSMASQ

In unserem Setup ist kein dnsmasq nötig – das wäre erforderlich, falls Sie keine bridge machen wollen, sondern den Clients eigene IP Adressen aus einem anderen Bereich geben wollen, z.B. aus Sicherheitsüberlegungen.

Windows – debugging, etc.

  • um die IP Adresse herauszufinden: unter Powershell: ipconfig /all
  • Es empfiehlt sich, die Funknetzwerkbelegung zu analysieren, um den Durchsatz zu optimieren. Unter Windows gibt es dazu bspw. das Tool InSSIDer. (Scheint kostenlos zu sein).

image

Dokumentation & weiterführende Links

Tools
  • InSSIDer – WiFi Analyse-Tool für Windows (auch mit Windows 8 kompatibel)
Waren
Optimization WordPress Plugins & Solutions by W3 EDGE