Understanding Automatic Connection Creation
When you plug an Ethernet cable into a Linux system running NetworkManager, the daemon scans for available physical interfaces. If it finds an interface like eth0 or enp3s0 that is not currently managed by any user-defined connection profile, it generates a new profile on the fly. This profile is typically named Wired-1, Wired-2, and so on, depending on how many such auto-generated connections exist.
This automatic creation serves a practical purpose: it allows systems to connect to networks immediately upon boot or hardware insertion, which is crucial for servers, desktops, and embedded devices like Raspberry Pi units where consistent network availability is required. However, for environments requiring strict network policies, static IP assignments, or specific routing rules, relying on auto-generated profiles can lead to management headaches because these profiles are often generic and lack the necessary custom configurations.
Identifying the Interface and Profile
To understand what NetworkManager has created, you first need to identify the underlying network interface and the associated connection UUID. Open a terminal and use the nmtui (Network Manager Text User Interface) utility or the nmcli command-line tool. Running nmcli connection show will list all active and inactive connections. Look for entries with the type 802-3-ethernet and names starting with Wired.
You can also check the status of your physical interfaces using ip link show. This command displays the state of each network card, indicating whether they are up, down, or in a promiscuous mode. By correlating the interface name from ip link with the connection name from nmcli, you can verify which physical port corresponds to the Wired-1 profile. This step is essential before making any changes to ensure you do not accidentally modify the wrong network path.
Managing the Default Wired Connection
If you wish to customize the Wired-1 connection, you should edit its properties rather than deleting it, as deletion might cause NetworkManager to recreate it with different parameters if the interface remains unmanaged. Use nmcli connection modify "Wired-1" ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 to set a static IP address, subnet mask, and gateway. Replace the example values with those appropriate for your local network infrastructure.
After modifying the connection, activate it again using nmcli connection up "Wired-1". This forces NetworkManager to apply the new settings. If you prefer a graphical approach, most desktop environments provide a network settings panel where you can click on the wired connection, select "Edit," and adjust IPv4 settings from "Automatic (DHCP)" to "Manual." This method is less error-prone for users unfamiliar with command-line syntax.
Preventing Unwanted Auto-Creation
In some cases, you may want to prevent NetworkManager from creating these default profiles entirely. This is particularly relevant if you are managing multiple interfaces and want to avoid confusion between auto-generated and manually configured connections. You can achieve this by setting the interface to be unmanaged in the NetworkManager configuration file, typically located at /etc/NetworkManager/NetworkManager.conf.
Add or modify the following line under the [keyfile] section: unmanaged-devices=interface-name:eth0. Replace eth0 with your actual interface name. After saving the file, restart the NetworkManager service using sudo systemctl restart NetworkManager. Note that this will disconnect the interface, so ensure you have an alternative way to manage it or that it is not critical for immediate operation. For more insights on service management during boot, see our guide on Optimizing Raspberry Pi Boot Time: NetworkManager.service Issue.
Troubleshooting Common Issues
Sometimes, despite having a static configuration, the system may still fall back to DHCP or fail to connect. Check the journal logs using journalctl -u NetworkManager for errors related to authentication, IP assignment, or route conflicts. Ensure that no other service, such as systemd-networkd or dhclient, is conflicting with NetworkManager's control over the interface.
If you encounter issues with DNS resolution after switching to a static IP, verify that the ipv4.dns property is set correctly in the connection profile. Missing DNS servers are a common cause of apparent connectivity failures where ping works but web browsing does not. Additionally, ensure that your firewall rules allow traffic on the configured subnet. For deeper dives into network configuration files and host resolution, refer to discussions on Dnsmasq Reads /etc/hosts, Ignores addn-hosts Configuration.
Frequently Asked Questions
Can I delete the Wired-1 connection?
Yes, you can delete it using nmcli connection delete "Wired-1", but NetworkManager may recreate it if the interface remains unconfigured. It is generally better to edit the existing profile to suit your needs rather than deleting it outright.
Why does my IP address change after reboot?
If you haven't assigned a static IP in the Wired-1 profile, NetworkManager defaults to DHCP, which assigns addresses dynamically. To fix this, explicitly set ipv4.method to manual and define the address, gateway, and DNS servers in the connection settings.
How do I bind a connection to a specific MAC address?
NetworkManager automatically binds wired connections to the physical interface's MAC address. You can verify this by checking the 802-3-ethernet.mac-address property in nmcli connection show "Wired-1". This ensures the configuration applies only to that specific hardware.
Is it safe to disable NetworkManager on a server?
Disabling NetworkManager requires you to manage network interfaces manually via /etc/network/interfaces or systemd-networkd. While this offers more control, it removes the convenience of automatic connection handling and may complicate dual-boot setups or desktop usage.
What causes duplicate Wired connections?
Duplicate connections often arise when multiple interfaces are present, or when a previous configuration was corrupted and recreated. Use nmcli connection show to identify duplicates and remove the unused ones to maintain a clean configuration state.