Connect your Pi to the internet

Wired Ethernet connection

Consumer routers are usually configured to issue an IP address to your devices via DHCP as soon as they are connected. This means that in most cases, connecting your Pi to the internet via a wired Ethernet connection is as simple as connecting your Raspberry Pi to your internet router/switch with a standard Ethernet cable.

Raspberry Pi connected to a switchRaspberry Pi connected to a switch

Raspberry Pi connected to a switch

Troubleshooting an Ethernet connection

Should you run into an issue on a wired Ethernet connection you should test the connection on your PC/laptop first. If your PC can get an internet connection on a wired Ethernet cable, typically the Pi can too.

Possible issues may include:

  1. A damaged Ethernet cable. This is pretty rare but it can happen.
  2. DHCP service may be turned off on your device and because of that your device is not being issued an IP address.
  3. If you're connecting through a USB-to-Ethernet adapter instead of default Ethernet port you might run into driver issues if your USB device is not natively supported in your chosen operating system. You may wish to try using the standard Pi Ethernet port first to establish if the issue is general, or is specific to the particular USB device you are using.
  4. A router or general internet fault. If you can't get any internet access via your router (including to your PC/laptop), you may need to replace the router and/or raise the issue with your ISP. They will probably ask the typical question 'have you power cycled it?', so it's worth giving that a shot too.

Wireless connection

👍

Please ensure the following before proceeding

  • You have a Raspberry Pi 3 or more recent
  • You have an official Raspberry Pi Operating system released in 2021 or more recently

The easiest and fastest way to configure WiFi on your Raspberry Pi is with the use of raspi-config utility. To launch raspi-config please use the following command:

sudo raspi-config

When raspi-config opens please follow the steps in the image below to configure your WiFi. All you need to do is to select the Country you're in, input your WiFi's name and password and then reboot the device.

After the device has rebooted there will be a background service running and attempting to connect to your WiFi. We can test it on a hotspot as in the example below:


Test your connection

"Ping" is the most common way to test a connection, whether you're connected on Ethernet or WiFi. The command below will send 5 packets to google and return connection statistics.

sudo ping -c 5 www.google.com

If you get returned an error such as "ping: unknown host www.google.com" or something other than the connection statistics it means your connection is not working.


Find your IP address

To find the IP address that you're currently using please use the command below:

hostname -I