Tuesday, March 19, 2024

Headless Raspberry Pi WLAN Configuration

I travel a lot and use my Raspberry Pi as media player in hotel rooms, however ever hotel has a different WLAN connection which would require that I adjust my Raspberry PI WLAN configuration in every hotel. Using my small bluetooth keyboard and the hotel TV was working, but I got upset because the keys on the remote are so tiny and I wouldn´t like to carry a big keyboard with me (additional to my Laptop). So I was searching for an easier option and here is what I did:

Since around 2016 the Raspberry Pi OS supports the option to configure the WLAN headless (that means without keyboard and screen). You only need to place a wpa_supplicant.conf inside the boot folder and during the reboot this file is moved from the boot partition inside the Raspberry Pi OS. So in every hotel, I quickly create a wpa_supplicant.conf with the following content:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

# Country code
# The ISO/IEC alpha2 country code for the country in which this device is
# currently operating.
#country=US
country=DE

# IEEE 802.1X/EAPOL version # wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which defines # EAPOL version 2. However, there are many APs that do not handle the new # version number correctly (they seem to drop the frames completely). In order # to make wpa_supplicant interoperate with these APs, the version number is set # to 1 by default. 0 might be used if the driver should handle this feature. # Note: When using MACsec, eapol_version shall be set to 3, which is # defined in IEEE Std 802.1X-2010. eapol_version=1

# ---------------------------------

network={
    ssid="YOUR_SSID"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

inside the boot folder from the SD-Card. Then I power up my Raspberry Pi and it will connected to the WLAN. I can then use my Bluetooth wireless remote control to access KODI / XMBC.

Additional I would like to get access to the device from my Laptop (in the case I would need to fix something), which isn´t working via the hotel WLAN as most Hotel WLANs do not allow that (for good reasons). So I use a small LAN wire to connect my Notebook and the Raspberry Pi. For that I use the following fixed connections:

host1 IP (PC): 192.168.0.1

host2 IP (Raspberry Pi): 192.168.0.2

Broadcast address: 192.168.0.3

Subnet: 192.168.0.0

SubnetMask: 255.255.255.252

Adding the IP to the LAN connection to the Laptop should be easily, however the Raspberry Pi configuration isn´t that easy if you aren´t family with it. So do the following:

1.) Edit the interface configuration on the Raspberry Pi via

sudo nano /etc/network/interfaces

and make sure it looks like the following:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.252
#broadcast 192.168.0.3
metric 100

Then save the file.

Voila, you now have a Raspberry Pi which can be quickly configured with creating a single file and which is then automatically connecting to the WLAN you specified in that file. You additional could connect to it via a private LAN connection if needed.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles