CodexBloom - Programming Q&A Platform

Ubuntu 20.04 - implementing Persistent Network Configuration after Reboot and 'Connection Timed Out' Errors

👀 Views: 1564 💬 Answers: 1 📅 Created: 2025-06-08
ubuntu networking netplan yaml bash

I'm attempting to set up This might be a silly question, but I'm dealing with I've been struggling with this for a few days now and could really use some help... I've been struggling with this for a few days now and could really use some help. I'm experiencing issues with the network configuration on my Ubuntu 20.04 server where the static IP settings are not being applied after a reboot. I set up a static IP configuration in `/etc/netplan/01-netcfg.yaml`, but after restarting the network service or rebooting the machine, the system falls back to DHCP, leading to 'Connection timed out' errors when trying to access the network. Here is the content of my YAML file: ```yaml network: version: 2 ethernets: enp0s3: dhcp: no addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 ``` After editing this file, I run `sudo netplan apply`, and there are no errors reported. However, after rebooting, I find that the interface is not taking the static IP and defaults back to a DHCP address. I’ve also checked the status of the network service with `systemctl status systemd-networkd`, and it shows that the service is active and running. I've confirmed that there are no typos or syntax errors in my YAML file by running `sudo netplan generate` and `sudo netplan apply` multiple times. To troubleshoot further, I tried creating a new YAML file with a different name, but the question continues. I also attempted to disable and re-enable the network interface using: ```bash sudo ip link set enp0s3 down sudo ip link set enp0s3 up ``` Any insights into why the static IP isn't being retained after reboot, or suggestions on alternative methods to configure the network settings persistently would be greatly appreciated. My development environment is macOS. What am I doing wrong? This is part of a larger CLI tool I'm building. Thanks in advance! I'd really appreciate any guidance on this. Is this even possible?