Setting up WiFi over SSH, without using DietPi-config

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Setting up WiFi over SSH, without using DietPi-config

Post by beerenheini »

Hi guys,

my raspberry pi 3 with latest dietpi installed is currently Running headless and is already connected via Ethernet.

As all traffic is dealt with by the USB Controller, I'd like to set up my Wireless Connection. Doing so with dietpi-config drops ethernet connection and obviously I lose being able to ssh into the pi. Unfortunately using keyboard and Monitor is not an option.

I understand that it's possible to enable wireless during/first/ boot but how do I deal with it if everything is set up already?

Some help would be appreciated!
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Setting up wireless headless

Post by Fourdee »

beerenheini wrote:Hi guys,

my raspberry pi 3 with latest dietpi installed is currently Running headless and is already connected via Ethernet.

As all traffic is dealt with by the USB Controller, I'd like to set up my Wireless Connection. Doing so with dietpi-config drops ethernet connection and obviously I lose being able to ssh into the pi. Unfortunately using keyboard and Monitor is not an option.

I understand that it's possible to enable wireless during/first/ boot but how do I deal with it if everything is set up already?

Some help would be appreciated!

Hi Beerenheini,

You will need to edit the following file:

Code: Select all

/etc/network/interfaces
And change the following lines, under the WiFi section:

Code: Select all

# Wifi
auto wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid MyWiFiRouter
wireless-key MyWiFiKey
wireless-mode Managed
wireless-power off
wpa-ssid MyWiFiRouter
wpa-psk MyWiFiKey
#dns-nameservers 8.8.8.8 8.8.4.4
Replace MyWiFiRouter and MyWiFiKey accordingly.

Once completed, test the connection:

Code: Select all

ifup wlan0
ifconfig wlan0
You can then disable the ethernet in:

Code: Select all

/etc/network/interfaces
Set:

Code: Select all

#auto eth0
Wlan0 will automatically connect during boot.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Re: Setting up wireless headless

Post by beerenheini »

Thank you Fourdee!

I've done as you told and this is what I get after

Code: Select all

ifup wlan0

Code: Select all

Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/b8:27:eb:e7:af:e3
Sending on   LPF/wlan0/b8:27:eb:e7:af:e3
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 19
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
No DHCPOFFERS received.
No working leases in persistent database - sleeping.
And after

Code: Select all

ifconfig wlan0

Code: Select all

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:e7:af:e3  
          inet addr:192.168.178.5  Bcast:192.168.178.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fee7:afe3/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:668 errors:0 dropped:79 overruns:0 frame:0
          TX packets:330 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:298018 (291.0 KiB)  TX bytes:92310 (90.1 KiB)
So the link should be up, right? I just want to make sure before I restart :)

Edit: iwconfig tells me

Code: Select all

# iwconfig 
wlan0     IEEE 802.11bgn  ESSID:"plattform_nomap"  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=1496 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          
lo        no wireless extensions.

eth0      no wireless extensions.
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Setting up wireless headless

Post by k-plan »

Hi Beerenheini,

Code: Select all

...
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
No DHCPOFFERS received.
...
what will you use in your home network, DHCP or static addresses?
Do yo want a static address on your DietPi?
Encryption is WEP/WPA/WPA2?

Using DietPi WLAN as DHCP Client:

Code: Select all

# Wifi
auto wlan0
iface wlan0 inet dhcp

wireless-essid ...
...
No ip address, netmask, gateway, dns, is needed. Will get it from your Wifi-Router, if it's configure as your DHCP Server correctly. But you need correct SSID, password, etc for WEP/WPA/WPA2, dependent on which encryption the access-point will use.

DietPi with static (fix) ip address (only examples!):

Code: Select all

# Wifi
auto wlan0
iface wlan0 inet static
    address 192.168.12.2
    netmask 255.255.255.0
    gateway 192.168.12.254
    dns-nameservers 192.168.12.254 8.8.4.4 

wireless-essid ...
...
... plus WEP/WPA/WPA2 keys as describe before.

cu
k-plan
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by beerenheini »

Thanks k-plan,

I think I've fucked things up - again. I wanted to update to 113, but I apparently did not have an Internet connection. Ifup couldn't read the configure file (must have been the missing wpa-psk). I started dietpi-config, went into Ethernet settings, changed them and applied. Connection dropped and here I am with no ssh.. I guess I' ll do a fresh install today and see how it goes. Why is that so hard for me? I remember those early days when I couldn't get my wifi card to work with wpa-supplicant. :$
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Re: Setting up wireless headless

Post by beerenheini »

k-plan wrote:Hi Beerenheini,

Code: Select all

...
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
No DHCPOFFERS received.
...
what will you use in your home network, DHCP or static addresses?
Do yo want a static address on your DietPi?
Encryption is WEP/WPA/WPA2?



... plus WEP/WPA/WPA2 keys as describe before.

cu
k-plan
Hi again,

(thanks for renaming the topic title BTW) I've installed dietpi 113 anew an now it seems to be working with this setup:

Code: Select all

# Wifi
auto wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid XXX
wireless-key YYY
wireless-mode Managed
wireless-power off
wpa-ssid XXX
wpa-psk YYY
#dns-nameservers 8.8.8.8 8.8.4.4
I had to configure the router at work to use „WPA Personal Mixed“ (DD-WRT), so I guess the problem is my fritzbox at home. How do I tell diet to only use WPA2? Thanks again!
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by k-plan »

Hi Beerenheini,

- Fritz!Box is DHCP-Server and use WPA2-PSK.
- SSID Fritz!Box: " SSID-of-your-fritz!box-here! "
- Wifi Password Fritz!Box: " WPA2-Pre-Shared-Key-of-your-fritz!box-here! "

- RPi will use DHCP

Edit nano /etc/network/interfaces like this (and save):

Code: Select all

...
# Wifi
auto wlan0
iface wlan0 inet dhcp
## address 192.168.0.100
## netmask 255.255.255.0
## gateway 192.168.0.1
## wireless-essid XXX
## wireless-key YYY
wireless-mode Managed
wireless-power off
wpa-ssid SSID-of-your-fritz!box-here!
wpa-psk WPA2-Pre-Shared-Key-of-your-fritz!box-here!
#dns-nameservers 8.8.8.8 8.8.4.4
Sometime is WPA2-PSK (WPA2Pre-Shared Key) also named "Wifi Passwort" or "WLAN Password" or "Secret"

My Test:

Code: Select all

:~# ifdown wlan0
Killed old client process

:~# ifup wlan0
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/b8:27:eb:e7:af:e3
Sending on   LPF/wlan0/b8:27:eb:e7:af:e3
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.0.1
DHCPACK from 192.168.0.1
bound to 192.168.0.222 -- renewal in 2747 seconds.
First we will use DHCP on WLAN for your RPi for testing. You will be connected at same time via SSH on eth0 . (LAN Copper-line)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by beerenheini »

Okay, after much testing I think I have the issue: https://github.com/raspberrypi/linux/issues/1355
It's a kernel bug and the hardware does not support channels 12 & 13 in Germany. Kernel 4.4 apparently fixes it.

Can you help me with upgraden the kernel in DietPi?

Thanks again for your great help!

Update:

I updated the Kerne to 4.4 with

Code: Select all

BRANCH=next rpi-update


but the problem still persists. My network does not appear in the network configuration in diet-config. Several others from my neighbors do. I Guess I'll have to wait until an update is available. I Don't want to switch to WPA.
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by k-plan »

Hi,
beerenheini wrote: I Guess I'll have to wait until an update is available. I Don't want to switch to WPA.
Switching to WPA will not solve your problem.
Change channels will do it. If possible, let your router set channel by itself.
( http://goo.gl/Edafoi )

Is it RPi3 with build-in Wifi or RPi with USB Wifi dongle?

Same Wifi devices build for USA market do not have support for channel 12 / 13. Sometimes a other firmware or driver can fix it.
But not always. USA certificated devices will not be free to do switching specifications by software after manufacturing. (not all)

Can you read german? http://www.elektronik-kompendium.de/sit ... 712061.htm
Dummerweise sind in den USA die Kanäle 12 und 13 nicht für WLAN freigegeben. Dort wird deshalb die Kanalverteilung 1-6-11 verwendet, was uns in Deutschland bzw. EU egal sein könnte. Leider unterstützen die in Deutschland erhältlichen Geräte die Kanäle 12 und 13 nicht immer. Beispielsweise wenn die Geräte für die USA hergestellt wurden. Die Rede ist von ca. 30% der in Deutschland erhältlichen Geräte. In diesen Fällen ist die Hardware und Software nicht auf das Frequenzspektrum in Deutschland und die EU angepasst. Das bezieht sich sowohl auf WLAN-Clients in Notebooks, Smartphones und Tablets, als auch auf WLAN-Basisstationen. Manchmal hilft ein Firmware- oder Treiber-Update. Wenn nicht, dann muss der WLAN-Adapter oder eventuell das ganze Gerät getauscht werden. Im Zweifelsfall muss man mit einem kastrierten Gerät leben.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
beerenheini
Posts: 16
Joined: Tue Mar 15, 2016 2:56 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by beerenheini »

Guys, thank you for your help! I switched the channel to "11" and now all is working. I've read that kernel 4.4 is now considered safe and that it should support channels 12 and 13 so probably I'll have a second go later on. But for now this topic should be solved.
k-plan wrote:Hi,
[...]
Is it RPi3 with build-in Wifi or RPi with USB Wifi dongle?
[...]
Can you read german? http://www.elektronik-kompendium.de/sit ... 712061.htm
It' the Pi3. Thanks for the interesting link. What a pity. Germany alone is a pretty big market...
Post Reply