0

I'm having "problems" with my Rpi 4 connection. Well, more than problems is that I think there's something I don't understand.

So the thing is that I have my Rpi connected to both wired network with eth0 interface and wireless network with the wlan0.

The thing is that the wired connection is a local network to I've made with an old router to communicate my computers but that actually don't have internet access. The internet access of the Rpi is via the wireless connection.

The problem that I have is that when I have the wired connection on the Rpi doesn't reach internet. I think this is because the it chooses as default gateway the one of the wired connection, which has no access to the internet. If I unplug the ethernet cable then the Rpi can access the internet with the wireless connection.

When both networks are on the route table locks like this:

pi@raspberrypi:~ $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.43.5    0.0.0.0         UG    303    0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.1.1     0.0.0.0         255.255.255.255 UH    100    0        0 eth0
192.168.43.0    0.0.0.0         255.255.255.0   U     303    0        0 wlan0

If in this configuration I ping I get:

pi@raspberrypi:~ $ ping raspberrypi.org
PING archlinux.org (4.3.2.1) 56(84) bytes of data.
From default (192.168.1.1) icmp_seq=1 Destination Net Unreachable
From default (192.168.1.1) icmp_seq=2 Destination Net Unreachable
^C
--- raspberrypi.org ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 2ms

however, if I ping when only the wireless is connected I get:

pi@raspberrypi:~ $ ping raspberrypi.org
PING raspberrypi.org (93.93.135.117) 56(84) bytes of data.
64 bytes from 93.93.135.117 (93.93.135.117): icmp_seq=1 ttl=49 time=146 ms
64 bytes from 93.93.135.117 (93.93.135.117): icmp_seq=2 ttl=49 time=145 ms
64 bytes from 93.93.135.117 (93.93.135.117): icmp_seq=3 ttl=49 time=176 ms
^C
--- raspberrypi.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 144.969/155.480/175.623/14.254 ms

I would like to know how I can make it so that the system chooses the connection gateway to the internet that actually has connection to the internet, or to be able to choose the wireless network over the wired to connect to the internet.

I would like, if possible, to do it without having to touch the dhcpcd.conf file and having to set a static IP.

Thanks a lot!

0

Add

interface eth0
nogateway

to the /etc/dhcpcd.conf

See Prevent dhcpcd from configuring a gateway on an interface in How to set up networking/WiFi

| improve this answer | |
  • Thank you very much! That worked. I learned about the metric of the connection and to change it so that the network manager assigns the first default gateway to the lower metric value – Ignacio López de Arbina Jun 24 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.