6

Scenario

  • wlan0 is configured to connect to an internet-connected router and gets 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.

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

3 Answers 3

4

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
0
7

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).

0

When I was trying the 2 posts out I added this:

interface eth0
nogateway

This did not work for me then I tried the next solution:

interface eth0 metric 300

interface wlan0 metric 200

But left the nogateway entry inside the /etc/dhcpcd.conf file, which deactivated the WLAN Adapter when I rebooted. I don't know why, if you choose the metric solution, make sure you remove also the nogateway entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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