OS: Raspberry Buster Lite
Board: Raspberry Pi 4
I have been playing with dhcpcd.conf for the last few days. I am trying to change the network settings from within a C++ program.
The program reads the new network settings from a .txt file and applies them correctly over (overwriting) dhcpcd.conf
and wpa_supplicant.conf
, respectively. And then it does system("ip link set eth0 down && ip link set eth0 up && ip link set wlan0 down && ip link set wlan0 up");
.
The thing is that the interfaces go down and then up but they don't have any IP assigned to them.
This is the current content of dhcpcd.conf:
interface wlan0
hostname PiWiFi
clientid PiWiFi
static ip_address=192.168.1.120/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
interface eth0
noipv4
noipv6
with wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MySSID"
psk="Password1234"
}
I have also tried this dhcpcd.conf:
interface wlan0
noipv4
noipv6
interface eth0
hostname PiEth
clientid PiEth
static ip_address=192.168.1.20/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
with wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
eth0 receives an IP Address ! wlan0 does not.
Also, I have tried disabling the service that runs the C++ program, rebooting the Raspberry and then manually changing dhcpcd.conf and wpa_supplicant.conf and it is the same story. wlan0 won't work.