I hope some can help me. I installed dhcpcd (to be able to use WiFi) on a custom Debian build for a Raspberry (so I can have a 64 bit OS). It seems to work all fine. The WiFi link is getting established as it should and the ethernet link works too. but it seems like dhcpcd doesn't add the default gateway. Disabling gets me default gateway for eth0 but wlan0 won't work then. I tried my best to reverse engineer Raspbian but at this point I'm stuck.

I haven't touched the /etc/dhcpcd.conf and even removing/renaming (because the file doesn't exist on Raspbian from what I can tell turns out it exists and ext2explore just couldn't properly read the SD card. Though the files are identical, after I checked it on a live system) didn't make any difference.

ip r gives me this output:

root@raspi# ip r
default dev eth0 proto kernel scope link metric 202
default dev wlan0 proto kernel scope link metric 303 dev eth0 proto kernel scope link src dev wlan0 proto kernel scope link src dev eth0 proto dhcp scope link src metric 1024 dev wlan0 proto dhcp scope link src metric 1024 dev eth0 proto kernel scope link src metric 202 dev wlan0 proto kernel scope link src metric 303

and route -n this:

root@raspi# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         U     202    0        0 eth0         U     303    0        0 wlan0   U     0      0        0 eth0   U     0      0        0 wlan0 UH    1024   0        0 eth0 UH    1024   0        0 wlan0     U     202    0        0 eth0     U     303    0        0 wlan0

For reference, this is the /etc/dhcpcd.conf:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.

# Use the hardware address of the interface for the Client ID.
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.

# Persist interface configuration when dhcpcd exits.

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=
#static domain_name_servers= fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=
#static routers=
#static domain_name_servers=

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

If you need more information, please let me know and I'll be happy to supply them.

Also adding the default gateway manually makes it work, but that's the job of the DHCP.

I found these questions, but they either use a static configuration, which is not what I want, have other unrelated issues, or are unsolved.

Also the image itself has been created with a slightly customized version of: https://github.com/drtyhlpr/rpi23-gen-image

  • because the file doesn't exist on Raspbian from what I can tell - you're mistaken, it's very much there and very important Commented Jan 22, 2019 at 8:19
  • @JaromandaX Then it seems ext2explore can't seem to correctly read the filesystem. I'll boot up my old copies and see if I can get the correct file then. Thank you!
    – BrainStone
    Commented Jan 22, 2019 at 8:22
  • @JaromandaX I just checked and the file on Raspbian is the same as on my custom Debian. (I even checked with a diff tool)
    – BrainStone
    Commented Jan 22, 2019 at 8:31
  • so it exists - not sure what your issue is though, I was just clarifying your error Commented Jan 22, 2019 at 9:08

4 Answers 4


As it turns out the issue was my /etc/network/interfaces file.

On my system it was just:

# Debian switched to systemd-networkd configuration files.
# please configure your networks in '/etc/systemd/network/'

So I changed it to be identical to the Raspbian one:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

Note the last line source-directory /etc/network/interfaces.d. Even though the directories are empty on both, not having that line breaks dhcpcd.


open /etc/dhcpcd.conf

make sure the option section looks like this (notice adding , routers and commenting the next line about classless_static_routers):

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name, routers
# option classless_static_routes

reboot and enjoy, tested on a pi 3b with buster


Below is how you set a default route out to the carrier. In my case wwan0 having a sim8200EA modem. This needs to be added so it loads on reboot.

sudo ip route add dev wwan0
  • You should add a METRIC if you have several interfaces. Commented May 6, 2021 at 20:41

On Raspberry Pi Zero and Zero W, the default /etc/network/interfaces contains a bunch of comments followed by a single line. First, make sure that's there.

source-directory /etc/network/interfaces.d

I remedied /etc/network/interfaces.d/00-interfaces (the only file in there) using inet dhcp, as suggested in https://wiki.debian.org/NetworkConfiguration

auto lo
iface lo inet loopback

auto wlan0
# fix no gateway at startup
iface wlan0 inet dhcp

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.