I run a Raspberry Pi at our university (Raspbian Stretch). I use it for a project where it has to rely on WiFi. I configured the connection using wpa_supplicant and it worked perfectly well. Now there's a problem with it, so I no longer get onto it using WiFi/ssh. I unplugged the SD card and modified /etc/network/interfaces
file to configure a static network that allows me to acces the Raspi over Ethernet. Here's the file:
source-directory /etc/network/interfaces.d
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.66.101
netmask 255.255.255.0
gateway 192.168.66.100
The Ethernet connection works perfectly, so I can acces my Raspi via ssh again. When I do /etc/init.d/neworking restart
, it takes a while, but I don't get a WiFi connection. When i run sudo systemctl restart dhcpcd.service
, it fails. systemctl status dhcpcd.service
says:
Feb 23 09:33:01 pren7 systemd[1]: Starting dhcpcd on all interfaces...
Feb 23 09:33:01 pren7 dhcpcd[3065]: Not running dhcpcd because /etc/network/interfaces
Feb 23 09:33:01 pren7 dhcpcd[3065]: defines some interfaces that will use a
Feb 23 09:33:01 pren7 dhcpcd[3065]: DHCP client or static address
Feb 23 09:33:01 pren7 systemd[1]: dhcpcd.service: Control process exited, code=exited status=6
Feb 23 09:33:01 pren7 systemd[1]: Failed to start dhcpcd on all interfaces.
Feb 23 09:33:01 pren7 systemd[1]: dhcpcd.service: Unit entered failed state.
Feb 23 09:33:01 pren7 systemd[1]: dhcpcd.service: Failed with result 'exit-code'.
So can't I use DHCP for wlan0 when I configure eth0 using a static IP? Is there a workaround? I cannot just deactivate eth0, because if the wlan0 connection fails, I need to modify the config directly on the SD card again.
EDIT: Following your suggestion, I switched from classic networking to dhcpcd. Here's my new /etc/network/interfaces
:
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
And here's my /etc/dhcpcd.conf
:
interface eth0
static ip_address=192.168.66.101/24
static routers=192.168.66.100
static domain_name_servers=8.8.8.8
iface wlan0 inet dhcp
as i did (see my edit above). – Patrick Bucher Feb 23 '18 at 10:41/etc/network/interface
is an anachronism - the default setting effectively does nothing - if you delete it networking continues. The only limitation isdhcpcd
detects ifdhcp
is used and disables itself (as the logs will show). – Milliways Feb 23 '18 at 11:10Raspbian
is ambiguous. – Milliways Feb 23 '18 at 23:31