Hydride
Posts: 1
Joined: Tue Dec 27, 2016 1:49 pm

Handle confliction between dhcpcd and /etc/network/interfaces

Fri Aug 25, 2017 8:20 am

I just upgrade the Raspbian from Jessie to Stretch in pi3 accroding to this site,.

dhcpcd 6.10.1
systemd 232
kernel 4.9.41-v7+

Problem

After reboot, dhcpcd failed to start, in /var/log/syslog, it shows:

Code: Select all

dhcpcd[399]: Not running dhcpcd because /etc/network/interfaces
dhcpcd[399]: defines some interfaces that will use a
dhcpcd[399]: DHCP client or static address
In my pi, eth0 is used for private network with static ipv4 and ipv6 address, and eth1 is used for public network with dynamic ipv4 and ipv6 address.

I failed in getting dynamic ipv6 address using /etc/network/interfaces, and have not found a way to setup both static ipv4 address and ipv6 address using dhcpcd.

Which means I need them both.

Attempt

So far, I found two interesting things.

One is that, when I execute

Code: Select all

sudo systemctl start dhcpcd
It failed.

But when I execute

Code: Select all

sudo dhcpcd -q -d
as systemd did, it succeeded.

Another things is that, when I move conflicting settings from /etc/network/interfaces into directory /etc/network/interfaces.d/ ,dhcpcd can be started by systemd successfully. Now I use this method to avoid confliction.



Hope this post could be helpful for people who encounter similar problem.

SurferTim
Posts: 1767
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Handle confliction between dhcpcd and /etc/network/interfaces

Fri Aug 25, 2017 10:35 am

If you do a fresh install of Stretch, this is the new /etc/network/interfaces file contents.

Code: Select all

# 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
edit: ifup and ifdown no longer function. You must use:
sudo ip link set wlan0 up
or
sudo ip link set wlan0 down
The Wifi must be turned on to do this.
Also, eth0 interface no longer works. You must use ifconfig to get the name of your ethernet device.

Colin123456
Posts: 1
Joined: Wed Sep 19, 2018 5:31 am

Re: Handle confliction between dhcpcd and /etc/network/interfaces

Wed Sep 19, 2018 5:34 am

The reason dhcpcd fails to start is because there are two versions in /sbin: dhcpcd3 and dhcpcd5. The one the system wants is dhcpcd5 but the one that is selected by default is dhcpcd3 (which is a wrapper for something else..) You can switch to dhcpcd5 in /etc/alternatives (via update-alternatives command)

hippy
Posts: 4031
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Handle confliction between dhcpcd and /etc/network/interfaces

Wed Sep 19, 2018 11:13 am

Hydride wrote:
Fri Aug 25, 2017 8:20 am
Another things is that, when I move conflicting settings from /etc/network/interfaces into directory /etc/network/interfaces.d/ ,dhcpcd can be started by systemd successfully.
Interesting. I had not seen this post previously. Having now moved my /etc/network/interfaces settings from that file, into a file in the interfaces.d sub-directory, returned the original to stock, it does appear to have removed at least some of the dhcpcd and related "failed" messages I was seeing on booting.

My guess is that whatever was producing those original "failed" messages does so by reading /etc/network/interfaces and looking for dhcp or static settings, but is only reading that file, not reading the files in the subdirectory. It probably therefore doesn't see those so doesn't fail as it does when the exact same is in /etc/network/interfaces.

Everything which was working seems to still be working, and some things which were not working have improved; the desktop network icon is now showing eth0 configured rather than the double-x disconnected icon, though still showing No Wireless Network on my Pi 3B.

I am sure it's not meant to be working, that hiding the settings in a sub-directory should not change things. Networking has become a complete nightmare for some since moving to dhcpcd and away from /etc/network/interfaces configuration.

I am also sure it's fine for most people who just connect to a router using DHCP, but it's a real pain, mess and mass of confusion for others. I would use the dhcpcd method of setting things up but, having wasted days trying to do that and it not working, I reverted to doing it 'the wrong way' because that is easy, a five minute edit, and just works. I have what I need if not things which would be nice to have but not entirely necessary.

Return to “Advanced users”