I have this configuration in /etc/network/interfaces:

auto lo
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan0
#iface wlan0 inet dhcp
        iface wlan0 inet static
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

iface eth0 inet static

The wireless static IP worked, but the eth0 didn't.

So I tried to do the config in /etc/dhcpcd.conf:

interface eth0
static ip_address=
static routers=
static domain_name_servers=

And it worked. I am confused and here are several questions:

  1. When to use which file?

  2. Why the wifi worked with /etc/network/interfaces but the eth0 didn't?

  3. Does dhcpcd has somehow priority over /etc/network/interface?

  4. How to check which service has priority or someting? And which service uses /etc/network/interface?

  • Pretty simple answer...you cannot give the same address space to two different networks/interfaces unless you bridge them, and turn them into a single network in the process. – Rui F Ribeiro Dec 20 '15 at 15:01
  • wlan is address and eth0 is address They are not the same. – CuriousGuy Dec 20 '15 at 15:04
  • let put it simply...eth0 and wlan0 cannot both belong to with your current config. – Rui F Ribeiro Dec 20 '15 at 15:05
  • still don't get it – CuriousGuy Dec 20 '15 at 15:11
  • @CuriousGuy each interface needs to have a single IP which will be a gateway for the network, so dhcp can serve the requests over that network. Let say eth0 is and wlan is – fugitive Jan 15 '18 at 20:12

Why the wifi worked with /etc/network/interfaces but the eth0 didn't?

By the network interface names, I assume you're talking about Raspbian Jessie or older; these will be different in Stretch and newer.

You did not tell it to either start at boot time (with auto eth0) or to start whenever the network hardware is detected (with allow-hotplug eth0).

If neither of those lines are present in /etc/network/interfaces, the interface eth0 will only start when an explicit manual ifup eth0 command is used.

Does dhcpcd has somehow priority over /etc/network/interface?

In Debian and related distributions, /etc/network/interfaces is generally intended to be the primary location for manual configuration of network interfaces; interfaces not listed in there will be controlled by NetworkManager, if it's installed.

However, the default start-up for dhcpcd5 apparently does not include a firm list of interfaces it can work on (to allow for hot-plugging, I guess), and it apparently can be used to circumvent the top-level control of /etc/network/interfaces by supplying the configuration in /etc/dhcpcd.conf instead.

Raspbian Stretch is actually using that as a standard practice.

I'm not too well versed in Raspbian specifically, but I think their solution may make sense: in a system with minimal resources, they may wish to minimize the number of different syntaxes their GUI/TUI configuration tools will need to be able to parse. If dhcpd.conf-like syntax is already used in some other configuration file, the decision to standardize on using that might allow more efficient reuse of configuration parser components.

When to use which file?

In a regular Debian system, I would recommend primarily using /etc/network/interfaces, and using /etc/dhcpcd.conf only for things you cannot achieve in /etc/network/interfaces, e.g. adding or manipulating the DHCP options you request/receive.

But it seems that for Raspbian Stretch and newer, the /etc/dhcpcd.conf is the recommended file.

|improve this answer|||||

1) Based on the answer to the question "How do I set up networking/WiFi/Static IP": if you are running dhcpcd, then edit dhcpcd.conf. See that link for the proper configuration of /etc/network/interfaces when dhcpcd is used.

2) It is unclear why changes to /etc/network/interfaces affected the wifi interface and not eth0. There are several subsystems involved so it could be a bear to debug.

3) As near as I can tell dhcpcd effectively ignores /etc/network/interfaces.

4) I don't think either dhcpcd or /etc/network/interfaces has priority, rather there is a clash resulting in unpredictable behaviour. ifupdown uses /etc/network/interfaces, and (IIRC) NetworkManager will respect 'manual' and 'static' entries. A quick scan of /lib/udev shows that udev calls ifup directly or systemd ifup@.interfaces which then calls ifup.

In my opinion: it isn't clear what advantages dhcpcd has over the old ifupdown method if using a static address on any interface. I have solved the unpredictable behaviour with the command sudo apt-get remove dhcpcd5

With regards to @Rui F Riberiro's comment about the addresses for eth0 and wlan0 being in the same subnet: Linux doesn't care if two interfaces are on the same subnet. Most home routers/access points bridge the wired and wireless lans therefore your configuration will likely work. Note that linux will use the first default route in the routing table therefore your computer may use the wifi interfaces even when the ethernet is connected.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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