-1

I've tried to set up a static IP on a RPi4 running the latest Raspbian Lite (Bullseye), so I can remove DHCP entirely.

My /etc/network/interfaces file looks like:

# Include files from /etc/network/interfaces.d:
auto lo
iface lo inet loopback

I also have /etc/network/interfaces.d/wlan0, which looks like:

auto wlan0
iface wlan0 inet static
  address 192.168.0.133
  netmask 255.255.255.0
  gateway 192.168.0.1
  dns-nameservers 192.168.0.1 8.8.8.8 4.4.4.4

If I run ip a, I get the following output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether e4:5f:01:20:e9:00 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e4:5f:01:20:e9:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.133/24 brd 192.168.0.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet 192.168.0.132/24 brd 192.168.0.255 scope global secondary dynamic noprefixroute wlan0
       valid_lft 6495sec preferred_lft 5595sec
    inet6 fdfc:b729:655a:4bd0:4620:dbb9:867b:fc3d/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 1654sec preferred_lft 1654sec
    inet6 fe80::eba1:157a:7b52:9b5c/64 scope link
       valid_lft forever preferred_lft forever

This looks legit and I can access the Pi on both ...132 and ...133. However, if I disabled dhcpcd.service, I can't access it anymore after a reboot (or if I manually stop dhcpcd.service)

I'm assuming that ifup is not called, but I may be completely off. It's a bit difficult to get a keyboard and display on the unit right now, which makes debugging this complicated (since I can't access it if it's not on the network).

Any suggestions are deeply appreciated.

EDIT:

I've started the system with DHCP disabled, left it a minute or two and shut it down, so I can have a look at the logs on a different machine. Seems like the network is going up as expected:

Jun 10 12:28:16 rpi-display systemd[1]: Starting Raise network interfaces...
Jun 10 12:28:16 rpi-display avahi-daemon[355]: Server startup complete. Host name is rpi-display.local. Local service cookie is 166240168.
Jun 10 12:28:17 rpi-display avahi-daemon[355]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.0.133.
Jun 10 12:28:17 rpi-display avahi-daemon[355]: New relevant interface wlan0.IPv4 for mDNS.
Jun 10 12:28:17 rpi-display avahi-daemon[355]: Registering new address record for 192.168.0.133 on wlan0.IPv4.
Jun 10 12:28:17 rpi-display systemd[1]: Finished Raise network interfaces.

Resolv.conf has the nameservers I configured:

# Generated by resolvconf
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 4.4.4.4

2 Answers 2

1

Option 1: Using /etc/network/interfaces.d

You need to provide wireless parameters in your /etc/network/interfaces.d/wlan0 file, either a path to a valid wpa_supplicant.conf:

auto wlan0
iface wlan0 inet static
  address 192.168.0.133
  netmask 255.255.255.0
  gateway 192.168.0.1
  dns-nameservers 192.168.0.1 8.8.8.8 4.4.4.4
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Or you need to provide the SSID and key in the file:

auto wlan0
iface wlan0 inet static
  address 192.168.0.133
  netmask 255.255.255.0
  gateway 192.168.0.1
  dns-nameservers 192.168.0.1 8.8.8.8 4.4.4.4
  wpa-ssid "MyNetworkName"
  wpa-psk "secretpassword"

Option 2: Using /etc/dhcpcd.conf

Remove your /etc/network/interfaces.d/wlan0 file.

Edit your /etc/dhcpcd.conf file. You will see the following example configuration:

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

Uncomment that and fill it in with appropriate values:

# Example static IP configuration:
interface wlan0
static ip_address=192.168.0.133/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8

Re-enable dhcpcd.service and reboot.


Incidentally, a USB serial cable like this is tremendously helpful in this sort of situation, because it allows you to plug you Pi into your desktop/laptop and access it via the serial console.

1
  • Thanks for the suggestion on the USB cable. Unfortunately, it's no-go here, because the GPIO is taken up by the display. I guess I could remove it, but it's a bit fragile and I'd want to avoid that. Commented Jun 11, 2023 at 9:30
-1

I've managed to solve this after I read the last post here and realised dhcpcd was starting wpa_supplicant on wlan0 through a hook.

After a bit more fiddling around, I realised I need to enable [email protected] manually. I copied over the wpa_supplicant.conf file to wpa_supplicant-wlan0.conf as it was complaining about missing that, though now that I read @larsks answer, I might have been able to point it to the config file through interfaces.d/wlan0.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.