IP address is used for identifying a device on a network. There are basically two types of IP addresses: 1) Public 2) Private. We can further divide these IP addresses into IPv4 and IPv6.
By default, Fedora uses DHCP-provided IP addresses when it is connected to a DHCP server. We can use the below methods to use static IP addressing and other networking options like vlans, bonds, bridges, teams, etc.
What will we cover?
In this guide, we will see two methods for setting a static IP on Fedora 33 workstation. Although this guide is performed on Fedora 33, it should also work on other Fedora versions. Let’s get started with this process.
Before you start
Please note that we have assumed that you have
- a basic understanding of IPv4 addressing and other computer networks basics
- knowledge of Linux command-line interface
- root access on the system or a user with root privileges.
- Fedora 33 OS installed on your system
Method 1. Using nmcli command-line utility for setting a static IP address on Fedora 33
Nmcli or NetworkManager Command Line Interface is a command-line utility for managing network connections. Users and scripts both use the nmcli utility to control NetworkManager. For e.g., you can edit, add, remove, activate or deactivate network connections. We can also use it to display the status of a network device.
The syntax of a nmcli command is as follows:
Step 1. To check the overall status of NetworkManager, use the command:
You can also use the below command to see a terse output about the connection state:
As you can see, it is showing a connected state for now. If you turn off the wired connection, it will change to a disconnected state. This is shown in below picture:
Step 2. Now, after connecting to a network, we can see the active connections on our system using:
You can also use the command below to see active and inactive interfaces:
As you can see, right now, only one connection is active on device enp0s3. To see the current network configuration for enp0s3, use the command:
You can also use the ip command:
Please note that our current IP is 10.0.2.15; we need to set it to 10.0.2.27.
Step 3. To change the IP of enps03 to a static IP, use the following command format:
Where network_uuid is as obtained in Step 2. ‘new_static_IP’ is the new IP we want to assign statically. If our new IP address is 10.0.2.27, then the command will be:
If you are feeling uncomfortable with the network UUID, you can also the connection name (Wired connection 1) as shown below:
NOTE: To avoid IP conflict, do not use an already assigned IP.
Step 4. Now configure the default gateway for our IP with the command:
Step 5. Now Set network DNS address using:
Step 6. Now we need to change the IP addressing scheme from DHCP to static:
Step 7. Now turn off and then turn on the connection to apply changes:
$ sudo nmcli connection up 'Wired connection 1.'
All the above steps are shown in the below picture:
Now again, check the Gateway and IP with the command:
$ ip addr | grep enp0s3
You can see the Gateway and IP addresses are both changed to the values we have set in the above steps.
Method 2. Using a graphical method for setting a static IP address on Fedora 33
This is a very straightforward way to set a static IP address on Fedora 33 OS; follow the steps below:
Step 1. On the Gnome desktop, go to the activities tab and search for Settings and launch it:
Step 2. In the left panel, you will see the network tab. Inside the network tab, click on the Settings icon as shown below:
Step 3. A new window will open, displaying the already configured IP addresses, Gateway, DNS as shown below:
Step 4. In the above window, select the IPv4 option from the top bar:
Step 5. Inside the IPv4 method segment, select the radio button corresponding to the manual option:
Step 6. When you select the manual method, it will open some text boxes for filling the IP addresses, DNS, Routes, and other information related to network configuration, as shown in the above image. We are adding the following details:
IP addresses: 10.0.1.27
We are leaving the Route segment row to be set automatically. See the reference picture below:
Step 7. Now we only need to stop and then restart the network connection using the connection switch in the main Network Tab as shown below:
- Switch Off
- Switch On
Step 8. Now we will verify if the new IP address, DNS, and Gateway are assigned properly. Go to the main Network Tab and click the settings icon as depicted in the picture below:
Step 9. I noticed that IP address, Gateway, and DNS are all changed to the new values that we have selected in the above steps:
That’s all for now; we have successfully set a static IP address on Fedora 33 workstation. We have seen both the command line and graphical methods. The CLI method is the only way to set the static IP address on non-gui or headless servers. The graphical method is more convenient for desktop users and novice Linux users.