Hi I'm trying to configure my Raspberry PI to work as a dhcp server. Idea is that through eth0 interface I will connect switch, to which I can connect other devices. But I still want to keep ssh and internet access through the wlan0.

To achieve I have installed isc-dhcp-server and then configured it by adding configuration for the static ip address to the /etc/network/interfaces.d/eth0

allow-hotplug eth0
iface eth0 inet static

Next I have added configuration for dhcp server to file /etc/dhcp/dhcpd.conf:

subnet netmask {
  option subnet-mask;
  option broadcast-address;
  option routers;
  option domain-name "local-network";
  option domain-name-servers,;

After that I have restarted Raspberry PI and everything seems fine I'm able to connect from my machine to it through the WiFi and other machines that are connected to switch are getting IP addresses from to (and I'm able to ssh to them through the configured Raspberry PI).

Biggest problem is that I'm not able to access internet from that Raspberry PI. When I type something like


it works, but


fails. After debugging the problem I managed to discover problem with command ip route:

default via dev eth0 proto dhcp src metric 202 
default via dev wlan0 proto dhcp src metric 303 dev eth0 proto dhcp scope link src metric 202 dev wlan0 proto dhcp scope link src metric 303

I have tried to remove default route via and it helps temporary, but after sometime some process (I suspect dhcp server) recovers it. Of course I can write a daemon that will remove it all the time, but I'm looking for some better solution.

Update #1

Without dhcp server ip route shows:

default via dev wlan0 proto dhcp src metric 303 dev eth0 proto kernel scope link src dev eth0 scope link src metric 202 dev wlan0 proto dhcp scope link src metric 303

Thanks in advance

  • It's unusual that eth0 is being configured with dhcp when it has a static setup. Are there any entries in /etc/network/interfaces or /etc/network/interfaces.d/* containing iface eth0 inet dhcp?
    – Torin
    Commented Jan 3, 2020 at 23:44
  • /etc/network/interfaces has only one line "source-directory /etc/network/interfaces.d", /etc/network/interfaces.d has only file that I have created above.
    – kobra
    Commented Jan 3, 2020 at 23:55
  • I am having similar issues and problems trying to setup a k8s cluster on my pis. However, I am seeing my master server getting on eth0 and seems to be pointed to the same mac address as
    – Shawn
    Commented Jan 4, 2020 at 0:06
  • If you are using stretch like I am it appears things have changed with networking. I am still trying to work out how to set this up. raspberrypi.stackexchange.com/questions/37920/…
    – Shawn
    Commented Jan 4, 2020 at 2:52

1 Answer 1


The problem is indeed the route table but I have successfully removed the route record without it returning.

As mentioned above, the networking in Stretch (back to Jessie I think) changed quite a bit. This post led me to instructions for setting up static IPs via modification of /etc/dhcpcd.conf instead of /etc/network/interfaces*. However, I discovered it was best in my situation to comment out the static router=x.x.x.x variable for my eth0 adapter static ip, as I did not want that to serve as my default gateway. I then simply removed the route from the table with ip route del default via <address> dev eth0 and it stayed deleted.

You won't be done here though, for internet access to work properly across your other devices connected to the dhcp server you will need to do the following to setup NAT:

1) Edit /etc/sysctl.conf to enable IP forwarding with the following toggle net.ipv4.ip_forward=1
2) Edit /etc/rc.local to add iptable rules for forwarding from eth0 to wlan0 and back. Add the following:

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o eth0 -m state \
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

3) Reboot for changes to take effect

Your other devices should now work as intended with wifi access and IPs assigned from your dhcp server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .