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?

Jakov
  • 173
  • 1
  • 4
  • 13

3 Answers3

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.

Ingo
  • 42,107
  • 20
  • 85
  • 197
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
RalfFriedl
  • 2,188
  • 2
  • 10
  • 11
  • It is written iface wlan0 inet dhcp, can dhcp be used for static IP? – Jakov Sep 28 '19 at 12:46
  • For static you have to add the information, I added the addresses from your example. – RalfFriedl Sep 28 '19 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 '19 at 01: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"
Luke A
  • 1
  • 1
    Jakov has already told us he's using Raspbian Buster, so your answer is off-topic. – Dougie Sep 29 '19 at 17:17
  • Are you suggesting netplan can be used in Raspbian? – Chenmunka Sep 29 '19 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 '19 at 19:38