Raspberry Pi online course

Connect a Raspberry Pi to the Internet with Ethernet

Connect a Raspberry Pi running Raspberry Pi OS to a router with Ethernet, verify DHCP network settings, and test internet access with ip addr and ping.

A wired Ethernet connection is a simple way to give a Raspberry Pi reliable access to a local network and the internet. This guide covers the physical connection, automatic DHCP configuration, address checking, connectivity testing, and common problems.

Understand the Ethernet connection

Ethernet is a wired networking technology. Raspberry Pi models with a built-in Ethernet port can connect directly to network equipment using an Ethernet cable.

The Ethernet port is the wider network socket on the Raspberry Pi board. Use a standard Ethernet cable with a matching plug at both ends. One end connects to the Raspberry Pi and the other connects to an available LAN port on an internet router or network switch.

A router connects the local network to the internet. It commonly includes several LAN ports and usually provides network configuration automatically. A switch can provide additional local-network ports, but it must ultimately connect to the router or another device that provides internet access.

Connect the Raspberry Pi to the router

  1. Make sure the router or network switch is powered on.
  2. Plug one end of the Ethernet cable into the Raspberry Pi Ethernet port.
  3. Plug the other end into an unused LAN port on the router or network switch. Do not use a port intended only for a different service, such as a dedicated telephone or broadband connection.
  4. Power on the Raspberry Pi, or reconnect the cable if the Raspberry Pi was already running.
  5. Wait briefly for the network connection to initialize. Link or activity indicators on the port may flash when a connection is detected.

How DHCP configures the connection

DHCP means Dynamic Host Configuration Protocol. In a typical home or office network, the router acts as a DHCP server. When the Raspberry Pi connects, it requests network settings and the router supplies them automatically.

DHCP commonly provides:

  • An IP address, which is the numeric address assigned to the Raspberry Pi on the network.
  • A subnet mask or network prefix, which identifies the local-network portion of the address.
  • A default gateway, normally the router address used to reach networks outside the local network.
  • DNS information. The Domain Name System translates names such as google.com into IP addresses.

For a standard router connection, manual IP configuration is usually unnecessary. The Raspberry Pi OS network service normally requests and applies these settings when the cable is connected.

Check the assigned IP address

Open a terminal and run the Linux network-address inspection command:

ip addr

Find the wired network interface in the output. It is commonly named eth0, although interface names can vary between systems. Under that interface, look for an inet entry containing an IPv4 address, for example:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
    inet 192.168.5.11/24 ...

An address such as 192.168.5.11 is a private local-network address. The /24 is a network prefix and describes which part of the address belongs to the local network.

Do not confuse the wired address with the loopback address. The loopback interface is commonly named lo and uses 127.0.0.1; it refers to the Raspberry Pi itself and does not prove that the Pi is connected to the router. Other output may show hardware addresses, IPv6 addresses, or interfaces that are currently unused.

For related command-line practice, see Terminal In Raspbian, Useful Terminal Commands, and Display Ip Address.

Test internet connectivity with ping

After confirming that the wired interface has an IPv4 address, test an external hostname:

ping google.com

A successful test displays reply messages, typically including the resolved address, response time, and a time-to-live value. Replies show that the Raspberry Pi can reach that host and that DNS successfully translated the hostname into an IP address.

The command may continue sending tests until you stop it. Press Ctrl+C to send the keyboard interrupt and return to the shell prompt.

64 bytes from ...: icmp_seq=1 ttl=... time=... ms
64 bytes from ...: icmp_seq=2 ttl=... time=... ms
^C

A hostname-based ping tests both network reachability and DNS name resolution. Therefore, failure can mean that the internet connection is unavailable, DNS is not working, or the destination does not answer ping requests. Some hosts block ICMP ping even when their websites are available.

What to verify after connecting Ethernet

CheckWhat to look forWhat it confirms
Physical linkEthernet cable securely connected and link or activity indication where availableThe Raspberry Pi is connected to network hardware
IP configurationAn IPv4 inet address on eth0DHCP or another network method assigned an address
Ping resultReply messages from an external hostnameInternet reachability and DNS resolution are working

Use the connection

Once the address and ping tests succeed, open the Raspberry Pi web browser and visit websites. The same active connection can be used for package updates, software downloads, and other network applications.

For example, you can continue with Update Raspbian to learn about updating installed software.

Troubleshoot a missing IPv4 address

If ip addr shows the wired interface but no IPv4 inet entry, check the physical connection and DHCP service.

  • Reconnect the cable at both ends and replace it if it may be damaged.
  • Try another LAN port on the router or switch.
  • Confirm that the router or switch is powered on and the port is active.
  • Reconnect the cable or restart the Raspberry Pi, then run ip addr again.
  • Check that DHCP is enabled on the router. It may be disabled in networks that require manually assigned addresses.

Troubleshoot a failed hostname ping

If the Raspberry Pi has a local address but ping google.com fails, the local link is working but the route to the internet or DNS may not be.

  • Check whether another device using the same router can access the internet.
  • Check the router's internet or WAN status.
  • Try another known hostname. A particular host may not respond to ping.
  • Consider whether a network policy blocks outbound traffic or ICMP ping traffic.
  • If names cannot be resolved, DNS information supplied by DHCP may be unavailable or incorrect.

Troubleshoot browser access

If the browser cannot open websites even though the cable is connected:

  • Run ip addr and confirm that the wired interface has an address.
  • Run the ping test before diagnosing the browser.
  • Try opening the router's local management page to distinguish local access from internet access.
  • Check whether a captive portal requires a sign-in, especially on managed or public networks.
  • Confirm that the browser is not set to offline mode and that DNS is available.