VMware ESXi and vSphere Cluster Management
Connect a Raspberry Pi to the Internet with Ethernet
Connect a Raspberry Pi to a router with Ethernet, obtain network settings through DHCP, inspect eth0 with ip addr, and test internet access with ping.
What you need
Ethernet is a wired networking method that connects a Raspberry Pi to a local network and, through a router, to the internet. Compatible Raspberry Pi models have an onboard Ethernet port: the physical RJ45 socket that accepts an Ethernet cable.
- A Raspberry Pi with Raspberry Pi OS or Raspbian installed
- An Ethernet cable
- A powered internet router, or a network switch connected to a router
- Access to a LAN port on the router
This lesson assumes that the Pi is set up and powered on and that you can open a terminal.
Connect the Raspberry Pi to the router
- Plug one end of the Ethernet cable into the Ethernet port on the Raspberry Pi.
- Plug the other end into a numbered LAN port on the router. Do not use the router's port marked Internet or WAN for the Pi.
- Wait briefly for the router and Raspberry Pi to establish a connection.
Many Ethernet ports have link or activity LEDs. A lit or blinking LED usually indicates that the physical connection is detected, although the exact LED behavior depends on the hardware. No lights can indicate a loose, damaged, or incorrectly connected cable, an inactive router port, or a hardware issue.
How automatic network configuration works
A typical home router acts as a DHCP server. DHCP, or Dynamic Host Configuration Protocol, automatically supplies network settings to devices that join the local network. Normally, you do not need to enter these settings manually.
After the cable is connected, DHCP can provide the Raspberry Pi with:
- An IP address, which identifies the Pi's network interface. A home network may assign an address such as
192.168.5.11. - A subnet mask or prefix length, which identifies which addresses belong to the same local network.
- A default gateway, usually the router's local IP address. The Pi uses it to reach destinations outside the local network.
- DNS server details. The Domain Name System translates names such as
google.cominto IP addresses.
Addresses in ranges such as 192.168.x.x are private local-network addresses. They identify the Pi inside the home or office network; they are not normally reachable directly from the public internet.
Inspect the wired interface with ip addr
Open a terminal from Raspberry Pi OS, then run:
ip addrThe ip addr command displays the Raspberry Pi's software-visible network interfaces. An interface is a connection that the operating system can use for networking. The wired Ethernet interface is commonly named eth0, though interface names can vary on some systems.
Look for an interface resembling this example:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
link/ether dc:a6:32:12:34:56 ...
inet 192.168.5.11/24 ...Interpret the important parts as follows:
- Interface name:
eth0is commonly the wired Ethernet interface. - Link state: flags such as
UPandLOWER_UPgenerally indicate that the interface is enabled and has a detected physical link. An interface marked administratively down is not ready for normal use. - IPv4 address and prefix: an entry beginning with
inet, such as192.168.5.11/24, shows an assigned IPv4 address and prefix length. - MAC address: the
link/ethervalue is the hardware address used on the local Ethernet network.
You may also see an interface named lo. This is the loopback interface, which lets programs communicate with the same Pi. Its usual address, 127.0.0.1, is local-only and does not prove that the Pi is connected to a network. For an Ethernet connection, locate an inet entry under eth0 or the actual wired-interface name.
Typical home-router example
- Connect the Pi to a router LAN port.
- Wait briefly while DHCP assigns settings.
- Run
ip addr. - Find an address such as
192.168.5.11undereth0.
At this point, the Pi has an address on the local network. Internet access still needs to be tested separately.
Test external connectivity with ping
ping is a command-line utility that sends connectivity probes to a destination and reports whether replies arrive. Test a public hostname with:
ping google.comA successful result includes reply lines similar to:
64 bytes from ...: icmp_seq=1 ttl=... time=...
64 bytes from ...: icmp_seq=2 ttl=... time=...These replies indicate that the Pi reached the destination and received responses. The hostname test checks two things together: DNS must translate google.com to an IP address, and the Pi must have a working route to the destination.
On many Linux systems, ping continues until you stop it. Press Ctrl+C after several replies to display summary statistics.
If you want to separate DNS from general routing, compare the hostname test with a public IP-address test, for example:
ping 8.8.8.8An IP-address test does not require the hostname to be resolved by DNS. However, a failed ping does not always prove that internet access is unavailable: some networks or destination hosts block ICMP ping. A web browser test can provide an additional check.
Use internet applications
After eth0 has a suitable address and an external connectivity test succeeds, open a web browser on the Raspberry Pi and access online resources. The same connection can be used for tasks such as updating Raspberry Pi OS software packages, downloading documentation, and installing applications.
Internet connection verification checklist
| Check | What to do | Expected result | What it confirms |
|---|---|---|---|
| Physical cable connection | Connect the Pi to a router LAN port and inspect link/activity LEDs where present. | The cable is seated and link indicators may light or blink. | A physical Ethernet link is likely available. |
| Interface state | Run ip addr and locate the wired interface. | The interface is present and active, commonly as eth0. | The operating system recognizes the wired connection. |
| DHCP-assigned IPv4 address | Inspect the inet entry under the wired interface. | A private address such as 192.168.5.11/24 appears. | The Pi received local network settings. |
| Ping to public hostname | Run ping google.com, then press Ctrl+C. | The name resolves and reply lines are received, unless the destination blocks ping. | DNS resolution and a route to an external host are working. |
Common network information shown by ip addr
| Item | Example form | Purpose |
|---|---|---|
| Interface name | eth0 | Identifies the software-visible wired connection. |
| Link state | UP, LOWER_UP | Shows whether the interface is enabled and whether a physical link is detected. |
| IPv4 address and prefix | inet 192.168.5.11/24 | Provides the Pi's local IPv4 address and the network prefix. |
| MAC address | link/ether dc:a6:32:12:34:56 | Identifies the Ethernet hardware on the local network. |
| Loopback interface | lo, 127.0.0.1 | Provides local-only communication and is not evidence of internet access. |
Troubleshooting
No wired interface address appears
If ip addr shows the interface but no IPv4 address under it, or the expected wired interface is not active, check the following:
- Reconnect both ends of the Ethernet cable.
- Try another cable or another router LAN port.
- Check link lights on the Pi and router, where available.
- Confirm that the router or switch port is powered and active.
- Check whether the router's DHCP service is enabled and still has addresses available.
- Confirm that another device on the same network can obtain an address.
- Restart the network connection, or reboot the Pi and router if appropriate.
The Pi has an address, but the hostname ping fails
An assigned address proves local configuration, not necessarily internet access. Possible causes include:
- The router itself has lost its internet connection.
- DNS service is unavailable or incorrectly supplied.
- A firewall or the target host blocks ICMP ping.
Check whether another device on the same router can browse the internet. Compare the hostname test with a permitted public IP-address test to help distinguish DNS problems from routing problems. Also try opening a website in the browser, because a failed ping alone does not always mean web access is unavailable.
Only 127.0.0.1 is visible
127.0.0.1 belongs to loopback and is local to the Pi. Locate eth0, or the actual wired-interface name, separately. If it has no assigned IPv4 address, recheck the cable, router LAN port, physical link, and DHCP service.