wired + wireless networking

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

wired + wireless networking

Postby rmjivaro » Mon Feb 18, 2013 1:31 pm

After a number of hours of failure, I finally got this to work by bowing to systemd.

Enable both wifi and wired networking at boot on the Raspberry Pi.
This provides a static IP for the wifi device. Configuring for a dynamic IP will require some modification of these instructions.

The object is to have both wired and wireless networking function after boot without user intervention.

This is how I did it, using Arch Linux 3.6.11-6-ARCH+ on the Raspberry Pi v2.

# Is there a kernel module for your hardware?
lsmod

# What is the device name of your wifi hardware?
systemctl --full -a | grep net-devices
# Mine was wlan0

# To maintain a reference, make a backup of the wpa_supplicant config file.
cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.orig

# Your wifi router password can be entered in the config file as text within double quotes, or as a hex
# value with no quotes. For security I chose to use the hex hash value, which is generated with:
wpa_passphrase 'mySSID' 'myPassphrase'

# Configure wpa_supplicant:
vi /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

# edit to read your personalized version of:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
ap_scan=1
fast_reauth=1
update_config=1
network={
ssid="Cisco59545"
psk=a9ec92e970a0669a016ef44b6
}

# end of file

# To test whether your configuration is valid, you can load it with:
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

# Using the -B switch will load it in the background so your terminal remains accessible, -i and -c are
# obvious. The man page can provide more information.
man wpa_supplicant


# If successful, you will have a loaded device but with no IP address assigned to it.
# Take a look:
ifconfig

# Ok great. Now let's unload it:
ifconfig wlan0 down

# And verify that it is down.
ifconfig

# And get on with the configuration of systemd so it will load at boot time.
# First, we need to load wpa_supplicant at boot time, using a service file ready-made for our purposes.
systemctl enable wpa_supplicant@wlan0.service

# And create the file that will assign the static IP to the interface.
vi /usr/lib/systemd/system/wifiaddr.service

# Edit to read your version of the following:

[Unit]
Description=Get wifi an IP addy
After=wpa_supplicant@wlan0.service

[Service]
ExecStart=/sbin/ifconfig wlan0 192.168.11.121 netmask 255.255.255.0

[Install]
WantedBy=multi-user.target

# end of wifiaddr.service

# And enable it.
systemctl enable wifiaddr.service

# Start the configuration. Since the wpa service has already been enabled, starting the wifiaddr service
# will cause its dependencies to start as well.
systemctl start wifiaddr.service

# Now reboot, and voila! Wired and wireless!

As you can see, systemd finds the device because the needed kernel module loaded. Mine loaded with no problem. You may have to take further steps if yours presents you with more challenges.

Once the device is present, the wpa_supplicant service file loads with that device as its dependency, and then the wifiaddr service file loads with the wpa_supplicant service as its dependency.
rmjivaro
 
Posts: 1
Joined: Mon Feb 18, 2013 1:12 pm

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 1 guest