There are good points in all the answers to this question, but I think that there is some scope for addressing your specific questions directly.
- When to use which file?
I'm going to make the assumption that you are suffering from a general degree of confusion that is occurring at the moment (in the wider Raspberry Pi community) with the introduction of Debian 'Jessie' in place of Debian 'Wheezy'. This change has made a large number of tutorials at worst obsolete and at best confusing.
The answer to the question is that when using Wheezy it was normal to make changes to the
/etc/network/interfaces file for the purposes of setting up network interfaces (go figure). When using Jessie, it will be necessary to make changes to '/etc/dhcpcd.conf'. However, if making changes to a wireless connection (
wlan0) you will also need to make changes to
/etc/wpa_supplicant/wpa_supplicant.conf which is where you add the network ssid and password.
- Why the wifi worked with /etc/network/interfaces but the eth0 didn't?
I'm not sure how the wifi connection could have worked since there is some information missing from your files (ssid at the least). As janos pointed out, the priority of the etho connection details coming after the wlan0 details probably made them operative (since they would have been seen last by the process reading the file).
- Does dhcpcd has somehow priority over /etc/network/interface?
No, they're different and are designed to suit different purposes under Jessie. For the purposes of using Jessie in a fairly simple way you can pretty much ignore the
interfaces file and work with
- How to check which service has priority or someting? And which service uses /etc/network/interface?
Again I'm going to make the assumption that the question is more of a 'Which file do I use and if I have to use one which takes priority?' question. The answer is that with the change from Wheezy to Jessie (and in a broader sense with the adoption of systemd) the configuration of `dhcpcd.conf' and 'wpa_supplicant.conf' will be the norm and the 'interfaces' file will be left to it's own devices.
What does this mean for you?
Well (again) making an assumption that you're trying to set up a hard wired (eth0) and wireless (wlan0) connections with static IP addresses, you would want your
interfaces file to be the default as it was initially installed;
# 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:
iface lo inet loopback
iface eth0 inet manual
iface wlan0 inet manual
iface wlan1 inet manual
You would want your
dhcpcd.conf file to include the connection details at the end of the file for both interfaces and the additional entries would probably look a bit like this;
# Custom static IP address for eth0.
# Custom static IP address for wlan0.
Lastly you would want to edit your
wpa_supplicant.conf file so that it includes the ssid for the wifi network and the password. It should probably look a bit like this;
I hope that covers it off. There is the very real possibility that my assumptions are incorrect, but since I recently went through a similar learning curve I'm hoping the data is useful.
I've actually written this up and you can get the information in the free ebook Just enough Raspberry Pi from Leanpub.
#raspbian. As a Un*x admin of many years, I find this fundamental change baffling compounded by an absolute dearth of documentation. I happened to find this question after spending an hour of trial and error. I wish I'd found raspberrypi.stackexchange.com/questions/37920/… earlier
ip addroutput and
systemctl status networkingoutput? Because if the OP tried to do that over ssh and using the eth0 ip to ssh into, then the modified eth0 ip will be assigned as secondary ip to eth0 to keep the ongoing ssh session uninterrupted, I tried to change the eth0 ip as the OP mentioned but sshing through wlan0 and it works and takes preference over dhcp, in my case it was dhclient on Stretch but sshing through eth0, the previous mentioned case takes place.