revert to dchcpcd

This commit is contained in:
Chris Frankland-Wright 2025-08-31 10:56:22 +01:00
parent 46892884a1
commit fdddf4eb76

View file

@ -294,25 +294,34 @@ EOF
sudo rm -f /etc/NetworkManager/conf.d/99-disable-dns.conf sudo rm -f /etc/NetworkManager/conf.d/99-disable-dns.conf
sudo systemctl reload NetworkManager sudo systemctl reload NetworkManager
# Configure a static IP for wlan0 using dhcpcd. # --- Configure networking for AP mode (using /etc/network/interfaces) ---
echo "Configuring static IP for wlan0 via dhcpcd..."
# Ensure dhcpcd is installed
sudo apt install -y dhcpcd5
# First, remove any existing configurations for wlan0 to prevent conflicts. # 1. Uninstall dhcpcd5 to prevent any conflicts.
# This is a more robust way to ensure our settings are applied. echo "Removing dhcpcd5 to switch to /etc/network/interfaces..."
sudo sed -i '/^interface wlan0/,/^\s*$/d' /etc/dhcpcd.conf sudo apt-get remove --purge -y dhcpcd5 || true
sudo systemctl disable dhcpcd || true
# Now, add our static IP config to the end of the file. # 2. Configure a static IP for wlan0 directly in the interfaces file.
sudo tee -a /etc/dhcpcd.conf > /dev/null <<EOF echo "Configuring static IP for wlan0 via /etc/network/interfaces..."
sudo tee /etc/network/interfaces > /dev/null <<EOF
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# Deny dhcpcd from managing the ethernet port to prevent conflicts source /etc/network/interfaces.d/*
denyinterfaces eth*
# Static IP configuration for Hachi Time AP # The loopback network interface
interface wlan0 auto lo
static ip_address=10.0.252.1/24 iface lo inet loopback
nohook wpa_supplicant
# The primary network interface (Ethernet) - managed by NetworkManager
allow-hotplug eth0
iface eth0 inet dhcp
# Static IP configuration for Fetch-Hachi AP
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.252.1
netmask 255.255.255.0
EOF EOF
# Configure hostapd for the Access Point # Configure hostapd for the Access Point
@ -377,8 +386,11 @@ echo "Disabling systemd-resolved to ensure dnsmasq has full control..."
sudo systemctl stop systemd-resolved || true sudo systemctl stop systemd-resolved || true
sudo systemctl disable systemd-resolved || true sudo systemctl disable systemd-resolved || true
# Restart dhcpcd to apply the static IP # Bring up the wlan0 interface manually
sudo systemctl restart dhcpcd echo "Bringing up wlan0 interface..."
sudo ifdown wlan0 || true
sudo ifup wlan0
# Restart hostapd to create the access point # Restart hostapd to create the access point
sudo systemctl restart hostapd sudo systemctl restart hostapd
@ -429,7 +441,7 @@ if [ "$IP_CHECK" == "10.0.252.1" ]; then
fi fi
else else
echo "❌ Error: wlan0 failed to get the static IP 10.0.252.1. Found: '$IP_CHECK'." echo "❌ Error: wlan0 failed to get the static IP 10.0.252.1. Found: '$IP_CHECK'."
echo "Please check 'sudo systemctl status hostapd' and 'sudo systemctl status dhcpcd'." echo "Please check 'sudo systemctl status hostapd' and 'cat /etc/network/interfaces'."
exit 1 exit 1
fi fi