I found out that manual network interface configuration should be done in /etc/dhcpcd.conf, not in (/etc/network/interfaces). Using the example right from the config file I added the following to the /etc/dhcpcd.conf file:

interface eth1
static ip_address=

The goal is to restrict eth1 interface to LAN only, so it does not connect to the internet. For that I intentionally omitted the static routers line, which I assumed was equivalent to the gateway specification in the /etc/network/interfaces file. However, PI still can connect to the internet - so maybe the "unspecified gateway" was defaulted and automatically added by the system?

I saw some suggestions to use the firewall, but I was hoping that there was a way to configure this specific interface through the network configuration file. I still want other interfaces like eth0 to be able to connect to the internet, so blocking WAN access through ufw may not be the best solution. Any suggestions on how to restrict eth1 interface to LAN only?

  • 1
    In case someone else has the same question - using keyword nogateway will do the trick.
    – Nazar
    Mar 14, 2021 at 2:51
  • 1
    You can add the fix as an answer and mark it so :-) Helps others see that there is a fix and stops the unanswered question coming back time and time again. Odd but perfectly acceptable practice here.
    – user130616
    Mar 14, 2021 at 4:30

1 Answer 1


Here's seems to be a simple solution - use nogateway keyword - reference dhcpcd.conf man(5):

  • nogateway Don't install any default routes.
  • gateway Install a default route if available (default).

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.