RaspberryPi:Networking

From UCT EE Wiki
Jump to navigation Jump to search

There are many ways to interface with the Pi. This page will cover types of network connectivity.

A Brief Overview of Networks

It is useful to have a basic idea of how networks, IP addresses, and subnets work. For this, it it suggested you read this article from Microsoft: https://tinyurl.com/y2z8x9za

Assigning a Static IP to the Pi

This section will assign a static Ethernet address to the Raspberry Pi. This is useful for your first configuration. If you have not done so, it is recommended you follow the instructions in Section[sec:Installation] to configure your Raspberry Pi.

  1. Insert the SD card into your computer and navigate to the BOOT partition

  2. Open “cmdline.txt” and append the following to the line (don’t create a new line)

    ip=192.168.137.15

    This tells the Raspberry Pi to configure the Ethernet port to use the IP address 192.168.137.15

  3. Enable SSH as per Section [sec:SSH].

  4. You need to configure your PC to use the same subnet as the Pi. To do so, see the information below in Section [sec:Connectivity-ChangeComputerIP]

Assigning a Static IP to your Computer

In order to use Ethernet for SSH, VNC, etc, it is required that the Pi and your computer all be on the same subnet. This section details how to do it. [sec:Connectivity-ChangeComputerIP]

Windows

To change the IP of your Ethernet port on Windows 10, complete the following steps:

  • Right click on your network option in Windows taskbar
  • Select“Open Network & Internet Settings”, on the lower right hand side of the screen.
  • Select “Change Adapted Options”
  • Right click on the Ethernet Connection and select “Properties”
  • Select “Internet Protocol Version 4 (TCP/IPv4) and click ”Properties"
  • Select “Use the following IP address:” and enter in the following options:

- IP Address: 192.168.137.1
- Subnet Mask: 255.255.255.0

  • You have successfully changed the IP of the Ethernet card on your computer. It is suggested that you now ensure connectivity by attempting to ping the Pi.
File:Figures/WindowsIPConfig
caption The IPv4 configuration screen in Windows 10

Ubuntu

To change the IP of your Ethernet port on Ubuntu, complete the following steps:

  • Click the network interface icon on the status bar and select Wired Settings
  • Click the gear button of the interface you’d like to change
  • Select the IPv4 Tab, and change the IPv4 method to Manual
  • Under “Addresses” enter in the following:

- IP Address: 192.168.137.1
- Subnet Mask: 255.255.255.0

  • You can leave Gateway and DNS blank
File:Figures/ubuntustaticip
caption The IPv4 configuration screen in Ubuntu 18.10

Ensuring connectivity

Sometimes you may want to debug your connection to the Pi. A fast way to do this is via the ping command. Ping sends a packet to a particular host (in this case the Pi), and measures the time taken for a response from that host.

To use the ping command, open a command prompt window or terminal and type the following:

$ ping 192.168.137.15

If that host is unreachable (the Pi hasn’t booted yet or is incorrectly configured), a message will show that the host is unreachable. If everything was correctly configured, you should get

Reply from 192.168.137.15: bytes=32 time<1ns TTL=64

This means your Pi and computer are both correctly configured. See section [sec:SSH] for configuring your Pi for SSH access.

NB: Don’t be surprised if you can’t ping a Windows machine from your Pi. Windows blocks the specific type of packet required for a ping in the firewall.