While working on my Raspberry Pi (OS 2023), I was connected to it via Ethernet for local control and file access. At one point, I needed to install a Python library from the internet — but the download kept failing, even though my Wi-Fi was connected and active.
After inspecting the network configuration using ip addr, I realized that both eth0 (Ethernet) and wlan0 (Wi-Fi) were up:
- `eth0` = Ethernet (local network: )
- `wlan0` = Wi-Fi (internet network:  )But the system was routing all traffic through Ethernet by default. Since the Ethernet connection was local-only and didn’t provide internet access, the Pi couldn’t reach external servers.
To solve this, I adjusted the network priority by editing the dhcpcd.conf file and assigning a lower metric to wlan0 and a higher one to eth0. This change ensured that Wi-Fi became the default route for internet traffic, while Ethernet remained available for local tasks like VNC or SSH.
After restarting the network service, the routing table confirmed that internet traffic was now flowing through Wi-Fi — and the library installed successfully.
This small fix turned into a valuable learning moment about routing tables, interface metrics, and how to balance multiple network connections on embedded systems.
When both Ethernet (eth0) and Wi-Fi (wlan0) are connected to a Raspberry Pi, the system often chooses Ethernet as the default route—even if it doesn’t have internet access. This can cause Wi-Fi-based internet to stop working as soon as the Ethernet cable is plugged in.
This behavior is controlled by the routing table, which selects the interface with the lowest metric value. By default, Ethernet usually has a lower metric than Wi-Fi. To fix this, we can manually adjust the metrics so that Wi-Fi becomes the preferred path for internet traffic, while Ethernet remains available for local tasks like VNC or SSH.
🔧 Step-by-Step Guide1. Edit the dhcpcd.conf file
Open the network configuration file:
sudo nano /etc/dhcpcd.confAdd the following lines at the end:
interface wlan0
metric 100
interface eth0
metric 300Lower metric = higher priority. This ensures wlan0 is selected for internet routing.
2. Restart networking
Apply the changes by restarting the DHCP client
sudo systemctl restart dhcpcdOr simply reboot the Raspberry Pi:
sudo reboot3. Verify the routing table
After rebooting, check the current routes:
ip routeYou should see a line like:
This confirms that Wi-Fi is now the default route for internet traffic.
To test internet connectivity, I ran:
ping -c 3 google.comIf successful, you’ll see replies from Google’s servers — confirming that Wi-Fi is now the default route.
✅ Result- Wi-Fi (wlan0) is used for internet access
- Ethernet (eth0) remains active for local control
- No need to unplug any cables during operation











Comments