3

I am trying to make static IP address on RPI 3B+ for both ethernet and Wi-Fi.

I was following this answer(How do I set up networking/WiFi/static IP address?), but still could not do it.

So far I managed to do it for ethernet, but I cannot do it for wlan0(Wi-Fi).

Moreover, when I type ifconfig, I see only eth0 and lo, not wlan0.

I am using Rasbpian Buster.

When I type ip link, I get following message:

3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether b8:27:eb:9a:0a:e1 brd ff:ff:ff:ff:ff:ff `

Part of /etc/dhcpcd.conf

# STATIC IP CONFIGURATION - ETHERNET
interface eth0
static ip_address=192.168.88.10/24
static routers=192.168.88.1
static domain_name_servers=192.168.88.1

# STATIC IP CONFIGURATION - WLAN
interface wlan0
static ip_address=192.168.88.200/24
static routers=192.168.88.1
static domain_name_servers=192.168.88.1

/etc/network/interfaces

source-directory /etc/network/interfaces.d

auto eth0
iface eth0 inet static
address 192.168.88.10
netmask 255.255.255.0
gateway 192.168.88.1

auto wlan0
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet static
address 192.168.88.200
netmask 255.255.255.0
gateway 192.168.88.1

/etc/wpa_supplicant/wpa_supplicant.conf

country=HR
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="SSID_NAME"
    psk="PASSWORD"
}

Can somebody tell me where is the problem?

  • Use the command ip link to see whether wlan0 exists. Or ifconfig -a if you prefer the legacy command. – RalfFriedl Sep 28 at 12:18
  • You should add the information to the question. So the driver for wlan0 is loaded, but it hasn't been brought up. You could try to bring it up manually with ifup wlan0. If it doesn't work, look at the system logs. – RalfFriedl Sep 28 at 12:24
  • I changed it. When I type ıfup wlan0, I get following message. ifup: /etc/network/interfaces:10: misplaced option ifup: couldn't read interfaces file "/etc/network/interfaces" – Jakov Kusić Sep 28 at 12:28
  • 3
    Take the stuff out of /etc/network/interfaces. Do everything in /etc/dhcpcd.conf ONLY. – Dougie Sep 28 at 13:46
  • 2
    Because it simply doesn't work the way you've done it. You'll end up with two addresses assigned to one interface. – Dougie Sep 28 at 15:30
2

There are some things mixed up or unclear why do you use unfamiliar setups. Please note that old style Debian ifupdown networking (with /etc/network/interfaces) is deprecated at least since Raspbian Stretch and you should avoid using it. That may conflict with default used dhcpcd. You find a note in /etc/network/interfaces saying:

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

But you set static ip addresses with dhcpcd and with /etc/network/interfaces. What setup should be used? That cannot work. Please restore /etc/network/interfaces to its default setting and don't touch it again.

The settings in /etc/dhcpcd.conf look good so far. Unclear is why you use two interfaces eth0 and wlan0 on the same subnet 192.168.88.0/24 with ip addresses 192.168.88.10 and 192.168.88.200. The kernel can only use one interface at a time to connect to the subnet. Having two interfaces on one subnet makes only sense if you want to have a failover interface if one fails. But it doesn't help much because on a failed interface all stateful TCP connections will stuck when the kernel switches to the other interface. If you want failover then you have to use another strategy with bonding. Here is an example Howto migrate from networking to systemd-networkd with dynamic failover.

With the available information I suggest just to set a static ip address in /etc/dhcpcd.conf only for your favorite interface as you already have done and delete the entry for the other interface.

  • @JakovKusić You should not set anything in /etc/network/interfaces. – Ingo Sep 30 at 8:30
  • I tested it now and you are right, nothing should be in /etc/network/interfaces – Jakov Kusić Sep 30 at 8:45
1

According to this Debian HowTo, the interfaces file should look like this:

allow-hotplug wlan0
iface wlan0 inet dhcp
        wpa-ssid myssid
        wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b

For static addresses you have to adapt the address configuration, but the wireless part is the same.

allow-hotplug wlan0
iface wlan0 inet static
        wpa-ssid myssid
        wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
        address 192.168.88.200
        netmask 255.255.255.0
        gateway 192.168.88.1
  • It is written iface wlan0 inet dhcp, can dhcp be used for static IP? – Jakov Kusić Sep 28 at 12:46
  • For static you have to add the information, I added the addresses from your example. – RalfFriedl Sep 28 at 13:03
  • The "Debian HowTo" DOES NOT cover dhcpcd - the default Raspbian network manager. The OP's problem is caused by attempting to use both (incompatible) methods. – Milliways Sep 30 at 1:52
0

In the latest version of Ubuntu and Debian, netplan is used. You need to add something similar to below in a file in /etc/netplan/ and have a file extension of .yaml. You can just add to the default file in /etc/netplan/:

wifis:
        wlan0:
             dhcp4: false
             addresses:
                     - 192.168.10.9/24
             routes:
                     - to: 0.0.0.0/0
                       via: 192.168.10.2
                       metric: 600
                     - to: 192.168.10.0/24
                       via: 0.0.0.0
                       metric: 600
             access-points:
                     "SSID goes here":
                        auth:
                           key-management: psk
                           password: "passwordhere"
  • 1
    Jakov has already told us he's using Raspbian Buster, so your answer is off-topic. – Dougie Sep 29 at 17:17
  • Are you suggesting netplan can be used in Raspbian? – Chenmunka Sep 29 at 17:46
  • Raspbian Buster is based on the latest Debian, I believe the latest Debian (I know the latest Ubuntu has) switched to using netplan as the default, and if you do not want it you have to change the config. – Luke A Sep 29 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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