Block I Illinois Library Illinois Open Publishing Network

Raspberry Pi Networking 1010

While the world originated analog, with physical data such as audio and visual signals that change continuously, we now also make regular use of digital signal processing to turn the continuous analog signals into number samples, often transmitted using binary 0/1 sets. A leading mechanism for sharing binary digital data streams of all kinds is the Internet Protocol. In this set of exercises, you’ll get a chance to connect your Raspberry Pi to a Local Area Network (LAN) and test out performance of the Raspberry Pi on the Internet.

Some choices of interest may include:

We live today in a wireless society. In some cases, even our phones no longer provide a plug-in for our wired headsets, moving us to instead primarily use Bluetooth headsets. When our mobile phones are located someplace in a building with limited cell service, we can make use of the building’s Wi-Fi connection to get us to that cell service. Our laptops and even many desktops today depend on Wi-Fi Internet access. After all, it’s much simpler and cleaner-looking than yet another wire.

When mobility, flexibility, and simplicity are important, wireless Ethernet connectivity is a solid choice.

But here are some key reasons why wired Ethernet remains the better choice for networking more often than you might think.

  • Performance: Wired Ethernet makes use of Cat5 or Cat6 cables that provide synchronous upload and download of data at either 100 Mbps or 1 Gbps. The 802.11a/b/g speeds are improving and can now provide creative forms of synchronous transfers of data at upwards of 54 Mbps. Wired Ethernet provides synchronous communication from a single computer to a switch. Meanwhile, the wireless radio waves are shared by all connected devices simultaneously, thereby changing performance without notice.
  • Reliability: Cat5/6 cables are designed to limit interference, and are often installed within walls or ceilings to further improve reliability. While WiFi has improved over the years, it remains susceptible to interference from a range of fixed and dynamic factors.
  • Security: While the wireless 802.11 protocol and interconnected devices used to provide network access to Wi-Fi devices have improved significantly, it remains that a wired Ethernet connection is less susceptible to security attacks than wireless Ethernet.

When doing some home improvements many years ago, I used the opportunity to run wired Ethernet to a few locations in each major room of the house. This helps improve performance of all devices, as the high-demand Roku, solar panel interface, and office computer all make use of the wired Ethernet Cat5b cables. And especially at times when many devices are making active use of the network, the 1-Gbps wired Ethernet connection has proved essential when I am teaching or collaborating online from my home office.

When consulted on new construction and Ethernet, I strongly recommend installation of as much wired Ethernet as possible, especially in libraries, schools, and community centers where there will be more statically located networked devices. This both improves performance, reliability, and security for these static devices and reduces demand for the many wireless devices within the space.

What about the Raspberry Pi? While it is capable of both wired and wireless networking, the choice may vary by project.

For basic educational and prototyping activities, especially when close access or mobility is important to work with breadboarding and electronic testing in a range of locations, Wi-Fi continues to be the preferred means of connecting to the LAN. However, when prototyping moves to the next level and is used for ongoing data collection and distribution—for instance, as a soil and weather sensor database system accessible via web server—I move the Raspberry Pi to a waterproof case and connect it to the LAN via an outdoor Cat5 cable. When the Raspberry Pi is used as a multimedia server or a location-based collective networking toolkit, I’ve found it ideal to locate the Raspberry Pi right next to the gateway router, connected via a short Cat5 cable.

When the Raspberry Pi is running headless (without a keyboard, mouse, and monitor), Secure Shell (SSH) is a quick and easy way to connect to and control the microcomputer. The Pi’s microSD card must be edited to enable SSH access within the Raspberry Pi Operating System, but after this, I can connect the Raspberry Pi to a router with a wired Ethernet cable. This will automatically provide it with an IP address that I can use to SSH into the Pi on its very first boot.

Exercise: Connect a Raspberry Pi to a Wired Ethernet Port

  1. Connect one end of an Ethernet cable to the wired Ethernet port on your Raspberry Pi.
  2. Connect the other end of the Ethernet cable to an available LAN Ethernet port. Some places where these may be found include:
    • An Ethernet port on the wall.
    • One of the four LAN ports commonly found on home and small office gateway routers used to connect to the Internet service provider.
    • An Ethernet switch that itself connects to a wall connection or to the gateway router for the LAN.
  3. Most home and small office gateway routers provide a quick guide with login and password information to help you connect to their web servers to determine the assigned IP address for connected devices.
A web browser connected to 10.0.0.1 displays the Netgear gateway router administrative portal and within in, a list of devices attached to this router.
A first look at the Netgear gateway router’s attached devices.
In the Netgear gateway router portal: a device is edited on the 'Edit Device' page.
Editing the newly connected, unknown device—the wired Ethernet Raspberry Pi.
In the Windows 10 PowerShell terminal, the commands hostname -I and ifconfig return IP address listings for that device.
The Raspberry Pi is connected with both wired and wireless Ethernet to the home gateway router, as viewed with a first ssh connection to the 10.0.0.29 address identifed using the Netgear web server’s Attached Devices tool. Note that eth0 is assigned the IP address 10.0.0.29, while the wlan0 is assigned the IP address 10.0.0.28.

Exercise: Connect to a Wi-Fi Network from the Raspberry Pi Desktop

A GUI is provided for setting up wireless connections with the Raspberry Pi OS. If you are not using the Raspberry Pi Desktop, you can set up wireless networking from the command line in the next exercise.[2]

Wireless connections can be made via the network icon at the right-hand side of the menu bar. If you are using a Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, left-clicking this icon will bring up a list of available wireless networks, as shown below. If no networks are found, it will show the message “No APs found—scanning…” Wait a few seconds without closing the menu, and it should find your network.

Note that on the Pi 3B+, which supports the 5G protocol, wireless networking is disabled for regulatory reasons, until the country code has been set. To set the country code, open the Raspberry Pi Configuration application from the Preferences Menu, select Localisation, and set the appropriate code.
The WiFi icon and list of available networks on a Raspberry Pi running the Raspbian Stretch OS.

The icons on the right show whether a network is secured or not, and give an indication of its signal strength. Click the network that you want to connect to. If it is secured, a dialogue box will prompt you to enter the network key.
A pop-up window asking for the WiFi password on a Raspberry Pi running the Raspbian Stretch OS.

Enter the key and click OK, and then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When it is ready, the icon will stop flashing and show the signal strength.

Exercise: Connect to a Wi-Fi Network via the Command Line

This method is suitable if you don’t have access to the graphical user interface normally used to set up Wi-Fi on the Raspberry Pi. It is particularly suitable for use with a serial console cable if you don’t have access to a screen or wired Ethernet.[3]

Step 1: Get Wi-Fi network details

  1. Connect your laptop to your Raspberry Pi via serial console and begin a remote terminal session to scan for Wi-Fi networks.
    1. Using a TTL to USB cable, connect the black TTL wire to a GPIO Ground pin, the white TTL wire to GPIO 14 (TXD or transmit), and the green TTL wire to GPIO 15 (RXD or receive).
    2. Attach the USB side of the cable to your laptop.
    3. Adafruit provides a lesson on how to run software in the Mac, Windows, and Linux operating systems to connect your computer to the Raspberry Pi from here.
  2. To scan for wireless networks, use the command:
  • sudo iwlist wlan0 scan 
  1. This will list all available wireless networks, along with other useful information. Look out for:
    • “ESSID:”testing”” is the name of the Wi-Fi network “testing.”
    • “IE: IEEE 802.11i/WPA2 Version 1” is the authentication used. In this case, it’s WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. Visit the FreeBSD manual for WEP hex keys, scrolling down to see the last example on the webpage.
  2. You’ll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router.

Step 2: Connect to a network through raspi-config

  1. Once you know the network name (SSID) and password, the quickest way to enable wireless networking is to use the command line raspi-config tool.
  2. From the Raspberry Pi terminal window, enter:
  • sudo raspi-config
  1. Select the Network Options item from the menu, and then the Wi-Fi option.
  2. On a fresh install, for regulatory purposes, you will need to specify the country in which the device is being used.
  3. Then set the SSID of the network, and the passphrase for the network.

Exercise: Unusual Additional Registration Requirements

Businesses, schools, libraries, and other organizations use various measures to restrict access to their network to enhance security. This often means that a password is required to access a network, whether wired or wireless; two-factor authentication may also be required. Sometimes, only registered devices can access a network. And sometimes, the level of registration determines what can be done over the network.

At the University of Illinois at Urbana-Champaign, two primary wireless Ethernet networks are available for general use: IllinoisNet and IllinoisNet_Guest. For the most part, IllinoisNet_Guest is used for easy first access to the core technical services. Visitors can use this to create a 24-hour login, while regular users can use this to gain up to 12-month access for certain devices, such as gaming consoles, streaming devices, and your Raspberry Pi. As one example, the following steps will help those who are part of the University of Illinois at Urbana-Champaign system to register their Wi-Fi nodes, such as a Raspberry Pi, to the IllinoisNet_Guest network.

MAC Address Overview

Before we start, let us take a step back and look at how devices are differentiated. In the Orange Unit, we learned how different integrated circuits perform different tasks in a device. For a device to connect to a network, it requires an integrated circuit called a Network Interface Card (NIC). There is a NIC for each type of network connection: Ethernet, Wi-Fi, and Bluetooth. The Raspberry Pi 3 includes all three NICs.

To differentiate between different NICs and different devices, each NIC is assigned a Machine Access Control (MAC) Address. The MAC address is comprised of 6 groups of 2 hexadecimal digits. Hexidecimals contain the numbers between 0-9, but also include the uppercase letters A-F, to give 16 possible digits. Some information about your device is contained in the MAC address, such as the vendor or manufacturer of your device.

Register Device

The following steps will walk you through registering your device.

First, you will need to find the MAC address of your Raspberry Pi’s Wi-Fi network card. To do so, open a terminal window in your Raspberry Pi and type the following command:

$ ifconfig wlan0

This will output the data related to your wireless network interface. The first line should contain:

Link encap:Ethernet       HWaddr XX:XX:XX:XX:XX

Instead of Xs, your MAC address for your Wi-Fi NIC will be printed.

Either write this down or leave the window open, as you will need this information to register.

Next, using your laptop, navigate to http://go.illinois.edu/illinoisnetdevices and log in using your NetID and password. Click the “Manage Devices” button.

The Guest Account Management portal for the University of Illinois wifi network, Illinois Net. An arrow points to the 'Manage Devices' menu item.

Click the “Create” button to create a device account.

Under 'Manage Devices,' an arrow points to the button to create a new device.

Insert the following information for each required field:

  1. MAC Address: Copy or type the MAC address found in the steps above.
  2. Device Name: IS401-RaspberryPi
  3. AirGroup: Leave the box unchecked.
  4. Account Activation: Now
  5. Notes: Leave empty unless otherwise needed.
  6. Terms of Use: Check box to accept the terms of use.

Click “Create.” Restart your Raspberry Pi before attempting to connect to the network.


  1. Instructions for Real VNC start at step 6 of Exercise: First Boot of the Raspberry Pi OS.
  2. Raspberry Pi learning resources and documentation are licensed under CC-BY-SA 4.0. This exercise is a remix of the “Wireless connectivity in the Raspberry Pi Desktop” tutorial.
  3. Raspberry Pi learning resources and documentation are licensed under CC-BY-SA 4.0. This exercise is a remix of the “Setting up a wireless LAN via the command line” tutorial.

License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

A Person-Centered Guide to Demystifying Technology, 2nd Edition Copyright © 2023 by Martin Wolske Copyright © 2023. Copyright “Ideating and Iterating Code: Scratch Example” © 2020 Betty Bayer and Stephanie Shallcross. Copyright “Introducing the Unix Command Line” © 2020 Martin Wolske, Dinesh Rathi, Henry Grob, and Vandana Singh. Copyright “Security and Privacy” © 2020 Sara Rasmussen. Copyright “Storytelling in the Information Sciences” © 2023 Yingying Han and Martin Wolske. This book is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book