0

Scenario

  • wlan0 is configured to connect to an internet-connected router and get an IP via DHCP
  • eth0 is set to a static IP (via /etc/dhcpcd.conf, different net than wlan0) and connected to a net with no router, gateway or DHCP server.

Goal

I want to talk to devices connected to eth0 while maintaining internet connectivity through wlan0.

Problem

As soon as a cable is connected, the internet connection goes away. The default route is always set to the non-existent gateway of eth0. Manually setting the default route to the gateway of wlan0 works, but I don't want to hardcode this, as wlan0 is connected to different networks with different IPs.

  • How have you "set to a static IP"? – Milliways Apr 9 at 1:13
2

As Ethernet isn't connected to internet you can disable this by adding the following at the bottom of :- /etc/dhcpcd.conf

interface eth0
  nogateway
  • Thanks, that works! – mniess Apr 9 at 14:43
0

Change the metric of the interfaces. In /etc/dhcpcd.conf the following setting works:

interface eth0
metric 300

interface wlan0
metric 200

Now the gateway assigned to wlan0 via DHCP will always be the default route (if present).

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.