I am currently working on Raspberry Pi 3B+ (Stretch 9) and I have been stumped on how to be connected online wirelessly while also having my LAN port configured to receive and send data via a crossover Ethernet cable to an external piece of hardware (Note: the hardware via the LAN port is being interrogated with a Java program and does not need a bridged connection). The hardware defaults to the following settings:

IP Address:
Subnet Mask:

I can make the hardware work by the edit shown below but it disables my wireless connection.

Editing the /etc/dhcpcd.conf with:

interface eth0
static ip_address=
static routers=
static domain_name_servers=

If this might be any help hardware works but disconnected wirelessly from the internet, here is the output of route -n:

Kernel IP routing table
        Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    202    0        0 eth0         UG    303    0        0 wlan0   U     202    0        0 eth0   U     303    0        0 wlan0

Edit: When disconnecting the Ethernet cable the wifi works again. As far as I can tell it is due to the default route of the Ethernet (thanks softweyr), however I am still unsure as to how to solve this. In "route -v" it shows:

Kernel IP routing table
        Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
        default         UG    202    0        0 eth0
        default         UG    303    0        0 wlan0   U     202    0        0 eth0   U     303    0        0 wlan0

Final Solution: I changed the hardware interface connection to so that eth0 and wlan0 would not be in the same subnet (thanks Ingo) and changed as follows: /etc/dhcpcd.conf

interface wlan0
static ip_address=undefined/24
static routers=undefined
static domain_name_servers=undefined

interface eth0
static ip_address=
static domain_name_servers=
  • It could be routing, please post info about IP on WiFi network and the output from route print.
    – MatsK
    Feb 4, 2019 at 19:30
  • Possible duplicate of Setting up a Raspberry Pi as an access point - the easy way
    – Ingo
    Feb 4, 2019 at 19:45
  • 1
    You updated you question by setting static domain_name_servers= in /etc/dhcpcd.conf. Please don't use this address as single ip address for e.g. a nameserver. It is not a single ip address and you cannot reach a network device with it. This address stands for the whole subnet (single addresses -, is the broadcast address).
    – Ingo
    Feb 12, 2019 at 10:36

2 Answers 2


As you already have found, the problem is default routing. You have two default routes:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    202    0        0 eth0
default         UG    303    0        0 wlan0

If the kernel does not know where to send packages it sends it to the gateway on the default route. Because it can only use one default route it has to decide what route to use. For this it uses the Metric. The route with the lowest Metric is used, so it will send unknown packages to gateway if the ethernet cable is plugged in. If you pull it out then the kernel uses the next available default route on interface wlan0 and sends unknown packages to gateway

Obviously only gateway has a connection to the internet. I don't know for what do you need gateway but it does not connect to the internet. So the first step is to avoid declaring it as gateway. Just delete the line static routers= in /etc/dhcpcd.conf. If you need to send data to a specific network behind gateway you have to define a static route on the RasPi.

There is another issue. You connect two interfaces eth0 and wlan0 to the same subnet The kernel can also use only one interface and decides it also using the Metric. If you want to use both interfaces at the same time and not using a bridge you have to use different subnets behind each interface, for example for eth0 and for wlan0. If you want a connection between the subnets then you have to use routing and enable ip forwarding.


Don't accept a default route on the Ethernet network. As long as the default route you get from the WiFi network remains the only default route, your Pi will route everything to the IP network for the Ethernet to the Ethernet interface, and everything else with go to the WiFi interface.

You can do this on Raspbian with the following stanza in /etc/dhcpcd.conf:

interface eth0
  no gateway

Note that this is dhcpcd configuration, the "client daemon".

How this works:

You have made your Pi a "dual homed host" now. When the IP network comes up, three entries are added to the IPv4 routing table:

  • A route to the IP network the Ethernet is on, for instance, via the Ethernet interface.
  • A route to the IP network the WiFi is on, for instance, via the WiFi interface.
  • A default route, that is used when no more specific route matches.

Routes are matched in most specific to least specific order. If you send a packet to an address in the range, or to the broadcast address, it will go out the Ethernet interface; similarly for packets addressed to the network and the WiFi interface. If you send a packet to an address not on either of these networks, the only route that matches is the default route, so the your TCP/IP stack will send it to the router via the WiFi interface.

You enabled this by not accepting a default route on the Ethernet, since that isn't connected to the Internet. Another solution would be to configure the DHCP server on that network to not give out default routes, since it isn't truly a gateway device.

Why it isn't going to work for you: your edit to the question clarified the problem significantly. You cannot have the WiFi and Ethernet networks both be the same network address -- -- and have a host be able to talk to both. Hosts can talk to two networks, but they have to be two network addresses. You're going to have to "Re-IP" one of the networks, either the WiFi or the Ethernet.

  • Can you expand on this on how this keeps my connection to the internet via wireless while also keeping the IP address and LAN port to accept the hardware I have via the Ethernet cable? I tried your suggestion as well as different variations to no avail. I will update my post with more details. Feb 6, 2019 at 17:55

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.