2

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

3 Answers 3

2

Now I figured it out, thanks for the link!

Raspi Setup

After copying image to SD card:

mount /dev/mmcblk0p1 /mnt # mount boot partition
touch /mnt/ssh # activates ssh
umount /mnt

mount /dev/mmcblk0p2 /mnt # mount root partition

Edit /mnt/etc/dhcpcd.conf:

# static ethernet interface for debugging
interface eth0
static ip_address=192.168.66.101/24
static routers=192.168.66.100
static domain_name_servers=8.8.8.8

Umount SD card:

umount /mnt

Remove SD card, plug it into the Raspberry.

On Arch Linux, set up the Ethernet as follows:

sudo ip link set enp0s31f6 up
sudo ip addr add 192.168.66.100/24 broadcast 192.168.66.255 dev enp0s31f6

Connect to Raspberry using ssh:

ssh pi@192.168.66.101 # default password: raspberry

Add WiFi credentials:

wpa_passphrase [essid] [passphrase] >> /etc/wpa_supplicant/wpa_supplicant.conf

Enable wpa_supplicant:

systemctl enable wpa_supplicant.service
systemctl start wpa_supplicant.service

Restart networking:

systemctl restart dhcpcd.service
1

You can continue to use obsolete Debian networking despite its limitations - it normally configures a single interface (your implementation is non-standard and it is anyone's guess what it would do).

Including dhcp in /etc/network/interface causes dhcpcd to disable itself.

However I suggest you use the recommended normal dhcpcd networking.

See How to set up networking/WiFi

4
  • I now tried to switch to dhcpcd. Can I use dhcp in iface wlan0 inet dhcp as i did (see my edit above). Feb 23, 2018 at 10:41
  • You haven't specified what OS you are using. The link specifies the correct settings for both Jessie/Stretch. /etc/network/interface is an anachronism - the default setting effectively does nothing - if you delete it networking continues. The only limitation is dhcpcd detects if dhcp is used and disables itself (as the logs will show).
    – Milliways
    Feb 23, 2018 at 11:10
  • I have, see the first line of my post. Feb 23, 2018 at 14:56
  • @PatrickBucher You should indicate OS in a tag, rather than expecting people to search your post. Raspbian is ambiguous.
    – Milliways
    Feb 23, 2018 at 23:31
0

Try to add line below to /etc/dhcpcd:

denyinterfaces wlan0
1
  • 3
    Welcome! This should rather be a comment on the original question, unless you'd like to expand on your answer?
    – Vincent P
    Dec 24, 2019 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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