Rocky9 automatic connect to wifi and static ip

Hi,

I have small home server with usb wireless device and Rocky9. I also have several wireless networks - main wifi does not reach always and i’m using repeaters, which are configured with different wifi SID name, but they all share same ethernet network. I need server to connect to wifi without question. If wifi is availabe, connect and dont ask or wait for anything. Additionaly wireless device itself must have static IP (as it is server).

If i undestand correctly, starting with RHEL9/Rocky9 it’s not possible to use ifcfg files anymore and NM is the only way to configure network.
However NM always requires manual interventsion to create a new connection.

And as i don’t know how to implement it with NM, i’m trying to somehow get round NM. As first step i created new systemd wpa_supplicant.service and let wpa_supplicant fully to handle wireless network connections. Wifi networks are pre-configured in wpa_supplicant.conf. This part works.

Next problem is, that i can’t configure wireless device to have static IP. NM refuses to do so if it cant handle wireless connections itself.

How to solve this issue? Can it be done (automatic wireless connectons and static ip for wireless device)?

Regards,

All routers have a DHCP server where you can assign a static IP address to clients/devices based on its MAC address. Manual configuration is not needed.

Hello,

As using dhcp is not an option for me and i pushed my ideas a bit further and found a solution.
I noticed, that with Ubuntu server i dont have this network problem. Ubuntu uses netplan and systemd-networkd as renderer. So here it is what i did with Rocky9.

  1. Disabled wifi device management within NetworkManager:
# cat /etc/NetworkManager/conf.d/100-unmanaged.conf 
[keyfile]
unmanaged-devices=type:wifi
  1. Installed “netplan-default-backend-networkd” package (epel repo), created a new configuration for usb wifi dongle like that:
#
network:
  version: 2
  renderer: networkd
  ethernets:
    wlp1s0f0u4:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.129/24]
      nameservers:
        addresses: [192.168.1.1, 1.1.1.1]
      routes:
        - to: default
          via: 192.168.1.1
  1. New wpa_supplicant.service (Note: this bugged me as hell, below is what finally works, Note2: keep an eye on selinux!):
[Unit]
Description=WPA supplicant
After=network-online.target
Wants=network.target
IgnoreOnIsolate=true

[Service]
Type=Simple
RemainAfterExit=yes
ExecStart=/usr/sbin/wpa_supplicant -s -c /etc/wpa_supplicant/wpa_supplicant.conf -D nl80211,wext -i wlp1s0f0u4
Restart=always
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
Alias=dbus-fi.w1.wpa_supplicant1.service
  1. wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
update_config=1
country=US
network={
        ssid="xxx"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }
network={
        ssid="yyy"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }
network={
        ssid="zzz"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }

I wish i could do it without netplan/networkd, but this is the situation i can live with at least for now.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.