How To Set Static IP Address on Fedora 42
In the world of Linux networking management, configuring a static IP address is an essential skill for system administrators and power users alike. While dynamic addressing works well for many scenarios, static IP configuration provides reliability and consistency necessary for servers, networking equipment, and specialized applications. Fedora 42, with its cutting-edge features and robust networking capabilities, offers multiple methods to set up static IP addresses to suit various needs and technical preferences.
This comprehensive guide will walk you through each approach to configuring a static IP address on Fedora 42, from graphical interfaces to command-line tools and configuration files. By the end, you’ll have the knowledge to implement a static IP configuration that persists across reboots and meets your specific networking requirements.
Understanding Networking Basics in Fedora 42
Before diving into configuration methods, it’s important to understand the fundamental networking concepts that apply to Fedora 42 systems. Networking in modern Linux distributions relies on several key components working together to provide connectivity.
NetworkManager serves as the primary networking service in Fedora 42, handling everything from connection establishment to interface configuration. This daemon-based service manages all aspects of your system’s network connectivity, working beneath whatever interface you choose to use, whether graphical or command-line based.
When working with IP addresses, you’ll encounter both IPv4 (like 192.168.1.100) and IPv6 (like 2001:db8::1) formats. IPv4 remains the most commonly used in local networks, though IPv6 adoption continues to grow. Fedora 42 fully supports both protocols with parallel configuration options.
Network interfaces in Fedora 42 follow predictable naming conventions that differ from traditional Linux names. Instead of eth0 or wlan0, you might see names like enp0s3 (for Ethernet) or wlp3s0 (for wireless), which provide more information about the physical location of the device on your system bus. This naming scheme helps maintain consistent interface identification even when hardware changes.
For static IP configuration, you’ll need to gather several pieces of information:
- The IP address you want to assign to your Fedora system
- Subnet mask (often expressed in CIDR notation like /24)
- Default gateway address (the router that connects to other networks)
- DNS server addresses (for name resolution)
Understanding the difference between static and dynamic addressing is crucial. While DHCP (dynamic) addressing automatically assigns these parameters, static addressing requires manual configuration but provides consistency for services that need a fixed address.
Prerequisites Before Configuration
Before changing your network configuration, ensure you have the necessary permissions and information. Configuration changes typically require root privileges or sudo access. Without proper permissions, changes may fail to apply or persist.
Gather the following networking details before proceeding:
- An available IP address within your network’s range (check with your network administrator)
- Your network mask (commonly 255.255.255.0 or /24 notation)
- The default gateway’s IP address (typically your router)
- Primary and secondary DNS server addresses
- Your network interface name
To identify your current network interface name, run the command:
ip addr show
This will display all network interfaces on your system. Look for the interface currently in use, likely starting with “en” for Ethernet connections.
As a precaution, back up any existing network configuration files before making changes. This allows you to revert if something goes wrong:
sudo cp /etc/sysconfig/network-scripts/ifcfg-* ~/network-backup/
Method 1: Using the NetworkManager GUI
For desktop Fedora 42 users, the graphical interface provides the most straightforward approach to setting a static IP address. This method doesn’t require memorizing commands or editing configuration files directly.
To begin, locate the network settings icon in the system tray (usually in the top-right corner of your GNOME desktop). Click on the icon and select “Settings” or “Network Settings” depending on your desktop environment.
In the Network settings window:
- Select the wired connection you wish to configure from the list of available connections
- Click the gear icon (⚙️) to open the connection properties
- In the IPv4 tab, change the method from “Automatic (DHCP)” to “Manual”
- Click the “Add” button to enter your static IP information
- Enter your desired IP address in the “Address” field
- Enter your subnet mask in CIDR notation (e.g., /24 for 255.255.255.0) in the “Netmask” field
- Enter your gateway address in the “Gateway” field
- In the DNS section, switch off “Automatic” and enter your DNS server addresses separated by commas
- Click “Apply” to save your changes
The NetworkManager will immediately attempt to apply these settings. If successful, your network icon may briefly disconnect and reconnect as the new configuration takes effect.
To verify your configuration was applied correctly, you can check your current IP address by opening a terminal and running:
ip addr show
Look for your interface in the output and confirm it shows the static IP address you configured.
If you encounter issues with the GUI method, common problems include:
- Permission errors (ensure you authenticated with your password when prompted)
- Connection failure (double-check all entered values for accuracy)
- DNS resolution issues (verify DNS server addresses are correct)
Method 2: Using NetworkManager CLI Commands
For users who prefer terminal-based configuration or are working with Fedora 42 Server without a GUI, the NetworkManager command-line interface (nmcli) provides powerful control over network settings.
First, identify your current connections with:
nmcli connection show
This command displays all network connections configured on your system. Note the name of the connection you want to modify (e.g., “Wired connection 1”).
To configure a static IP address using nmcli, execute the following command, replacing the values with your specific network information:
sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1
This sets your connection to use a static IP of 192.168.1.100 with a subnet mask of 255.255.255.0 (/24) and gateway of 192.168.1.1.
Next, configure DNS servers:
sudo nmcli connection modify "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"
This sets Google’s DNS servers as your primary and secondary DNS resolvers.
To ensure the connection automatically activates at boot:
sudo nmcli connection modify "Wired connection 1" connection.autoconnect yes
Finally, apply the changes by bringing the connection down and up:
sudo nmcli connection down "Wired connection 1"
sudo nmcli connection up "Wired connection 1"
To verify your configuration, use:
nmcli device show
This command displays detailed information about your network devices, including IP address, gateway, and DNS settings.
The nmcli method offers several advantages for server environments:
- It can be used in scripts for automated deployment
- It works on systems without graphical interfaces
- It provides precise control over all connection parameters
- Changes apply immediately without requiring a full system reboot
If you need to modify specific aspects of your configuration later, you can run individual modify commands without reconfiguring everything.
Method 3: Editing Network Configuration Files
For advanced users or those coming from other Linux distributions, directly editing configuration files provides the most granular control over network settings.
The primary configuration file for your network interface resides in /etc/sysconfig/network-scripts/
. The filename follows the pattern ifcfg-<interface>
, where <interface>
is your network interface name (e.g., ifcfg-enp0s3).
To edit this file, use a text editor with root privileges:
sudo nano /etc/sysconfig/network-scripts/ifcfg-enp0s3
A typical configuration file for static IP addressing should contain these parameters:
DEVICE="enp0s3"
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=yes
TYPE=Ethernet
Let’s examine these parameters:
DEVICE
: Your network interface nameBOOTPROTO
: Set to “static” for fixed IP addressing (change from “dhcp”)ONBOOT
: Set to “yes” to activate the interface at boot timeIPADDR
: Your desired static IP addressNETMASK
: Your subnet mask in dotted decimal notationGATEWAY
: Your network gateway/router addressDNS1
,DNS2
: Primary and secondary DNS server addressesNM_CONTROLLED
: Whether NetworkManager manages this interfaceTYPE
: Connection type, usually Ethernet for wired connections
After saving your changes, restart the NetworkManager service to apply them:
sudo systemctl restart NetworkManager
Alternatively, you can bring the interface down and up:
sudo ifdown enp0s3
sudo ifup enp0s3
This method gives you complete control over the configuration but requires more careful attention to syntax and parameters. A single mistake can lead to connectivity issues, so double-check your entries before saving.
Configuring DNS Settings
Proper DNS configuration is crucial for name resolution, allowing your system to translate domain names to IP addresses. In Fedora 42, DNS settings can be configured through multiple methods.
When using NetworkManager (GUI or nmcli), DNS servers are typically set as part of the connection configuration. However, for more advanced setups or troubleshooting, you may need to work with the system’s DNS resolution services directly.
Fedora 42 uses systemd-resolved for DNS resolution by default. To configure custom DNS servers with systemd-resolved, create a configuration file:
sudo mkdir -p /etc/systemd/resolved.conf.d/
sudo nano /etc/systemd/resolved.conf.d/resolved.conf
Add the following content, replacing the IP addresses with your preferred DNS servers:
[Resolve]
DNS=192.168.1.1 8.8.8.8
Domains=yourdomain.local
After saving, restart the systemd-resolved service:
sudo systemctl restart systemd-resolved.service
You can verify your DNS configuration using the resolvectl command:
resolvectl
This displays your current DNS configuration, including configured servers and domains.
If you prefer to use the traditional /etc/resolv.conf
approach, you may need to disable systemd-resolved first:
sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved.service
Then edit /etc/resolv.conf
:
sudo nano /etc/resolv.conf
Add your DNS servers:
nameserver 8.8.8.8
nameserver 8.8.4.4
search yourdomain.local
The search
directive specifies the domain to append to unqualified hostnames, which helps with local network name resolution.
Testing and Verifying Your Configuration
After applying your static IP configuration, thorough testing ensures everything is working correctly.
First, verify that your IP address was properly assigned:
ip addr show
You should see your configured static IP address listed under your network interface.
Test local network connectivity by pinging your gateway:
ping -c 4 192.168.1.1
If successful, check internet connectivity by pinging an external server:
ping -c 4 8.8.8.8
Verify DNS resolution by pinging a domain name:
ping -c 4 google.com
If the ping succeeds, DNS resolution is working correctly. If it fails while the IP-based ping works, you may have DNS configuration issues.
To ensure your configuration persists after a reboot, restart your system:
sudo reboot
After the system comes back up, run the verification steps again to confirm your static IP configuration has persisted.
For a comprehensive network verification, you can also check routing information:
ip route show
This displays your routing table, which should include a default route through your configured gateway.
Advanced Static IP Configurations
Beyond basic static IP setup, Fedora 42 supports advanced configurations for specialized network environments.
Multiple IP Addresses on a Single Interface
To assign multiple IP addresses to the same interface using nmcli
:
sudo nmcli connection modify "Wired connection 1" ipv4.addresses "192.168.1.100/24 192.168.1.101/24"
This assigns two IP addresses to your interface, which can be useful for hosting multiple services.
When using configuration files, add additional address entries:
IPADDR0=192.168.1.100
PREFIX0=24
IPADDR1=192.168.1.101
PREFIX1=24
Network Interface Bonding
For increased reliability or throughput, you can configure network bonding (combining multiple physical interfaces into one logical interface):
sudo nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100"
sudo nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp1s0 master bond0
sudo nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname enp2s0 master bond0
Then configure your static IP on the bond interface:
sudo nmcli connection modify bond0 ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.method manual
IPv6 Configuration
To configure a static IPv6 address alongside IPv4:
sudo nmcli connection modify "Wired connection 1" ipv6.addresses 2001:db8::2/64 ipv6.gateway 2001:db8::1 ipv6.method manual
If you need to disable IPv6 entirely:
sudo grubby --update-kernel=ALL --args="ipv6.disable=1"
Static Routes
For complex networks requiring specific routing rules:
sudo nmcli connection modify "Wired connection 1" +ipv4.routes "192.168.2.0/24 192.168.1.254"
This adds a route directing traffic for the 192.168.2.0/24 network through the gateway at 192.168.1.254.
Troubleshooting Common Static IP Issues
Even with careful configuration, network issues can arise. Here are solutions to common problems with static IP configurations on Fedora 42:
IP Address Conflicts
If you experience intermittent connectivity, another device might be using your IP address. To check for IP conflicts:
arping -D -I enp0s3 192.168.1.100
If you receive responses, another device is using your IP. Choose a different address and reconfigure.
Gateway Connectivity Problems
If you can’t reach other networks despite having a valid IP address, check your gateway configuration:
ip route | grep default
If missing or incorrect, reconfigure your gateway:
sudo nmcli connection modify "Wired connection 1" ipv4.gateway 192.168.1.1
sudo nmcli connection up "Wired connection 1"
DNS Resolution Failures
If you can ping IP addresses but not domain names, DNS resolution is failing. Verify your DNS configuration:
cat /etc/resolv.conf
If using systemd-resolved:
resolvectl status
To test DNS specifically:
dig google.com
If DNS servers are unreachable, check if your firewall allows DNS traffic (port 53).
Configuration Persistence Issues
If your settings revert after reboot, check the following:
1. Ensure NetworkManager is not overriding your settings:
sudo grep -r "NM_CONTROLLED" /etc/sysconfig/network-scripts/
2. Verify file permissions for configuration files:
ls -l /etc/sysconfig/network-scripts/ifcfg-*
Files should have 0600 permissions (readable/writable only by root).
3. Check for conflicting configurations:
sudo ls -l /etc/NetworkManager/system-connections/
Remove any duplicate connections for the same interface.
NetworkManager Service Issues
If NetworkManager seems unresponsive:
sudo systemctl status NetworkManager
If it shows errors or is not running:
sudo systemctl restart NetworkManager
For persistent problems, check the logs:
sudo journalctl -u NetworkManager
Best Practices for Network Management
Implementing these best practices will ensure a reliable and well-managed network configuration on your Fedora 42 system:
Document Your Network Configuration
Maintain documentation of your network settings, including:
- Static IP addresses and their assigned devices
- Subnet information
- Gateway addresses
- DNS server configurations
- Any special routing rules
This documentation proves invaluable during troubleshooting or when reconfiguring after system changes.
Plan Your IP Address Scheme
For environments with multiple devices, develop a coherent IP addressing plan:
- Reserve specific ranges for servers with static IPs
- Consider using different subnets for different types of devices
- Leave room for expansion
- Avoid conflicts with DHCP address pools
Implement Security Considerations
Static IP addresses can increase security if properly managed:
- Configure firewall rules to restrict access based on IP addresses
- Regularly review network access policies
- Consider separating critical services onto isolated network segments
- Disable unnecessary network services
Use Fedora’s built-in firewall tool to manage access:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
Regular Testing and Monitoring
Implement a schedule for network verification:
- Periodically test connectivity between network segments
- Monitor for unauthorized devices on your network
- Verify DNS resolution performance
- Check for routing inefficiencies
Tools like ping
, traceroute
, and mtr
can help identify issues before they affect users.
Congratulations! You have successfully set up a static IP address. Thanks for using this tutorial to set a static IP address on Fedora 42 Linux system. For additional help or useful information, we recommend you check the official Fedora website.