IP address configuration is one of the normal tasks system administrators do on a System.


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

  1. a basic understanding of IPv4 addressing and other computer networks basics
  2. knowledge of Linux command-line interface
  3. root access on the system or a user with root privileges.
  4. 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:

nmcli [OPTIONS] OBJECT { COMMAND | help }

Step 1. To check the overall status of NetworkManager, use the command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/1-18.png" data-lazy- height="222" src="data:image/svg xml,” width=”976″>

You can also use the below command to see a terse output about the connection state:

$ nmcli -t -f STATE general

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/2-11.png" data-lazy- height="306" src="data:image/svg xml,” width=”984″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/3-12.png" data-lazy- height="348" src="data:image/svg xml,” width=”983″>

Step 2. Now, after connecting to a network, we can see the active connections on our system using:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/4-10.png" data-lazy- height="170" src="data:image/svg xml,” width=”975″>

You can also use the command below to see active and inactive interfaces:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/5-11.png" data-lazy- height="278" src="data:image/svg xml,” width=”983″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/6-9.png" data-lazy- height="453" src="data:image/svg xml,” width=”976″>

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:

$ sudo nmcli connection modify network_uuid IPv4.address new_static_IP/24

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:

$ sudo nmcli connection modify f02789f7-9d84-3870-ac06-8e4edbd1ecd9 IPv4.address 10.0.2.27/24

If you are feeling uncomfortable with the network UUID, you can also the connection name (Wired connection 1) as shown below:

$ sudo nmcli connection modify ‘Wired connection 1’ IPv4.address 10.0.2.27/24

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/7-8.png" data-lazy- height="202" src="data:image/svg xml,” width=”970″>

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:

$ sudo nmcli connection modify ‘Wired connection 1’ IPv4.gateway 10.0.2.11

Step 5. Now Set network DNS address using:

$ sudo nmcli connection modify ‘Wired connection 1’ IPv4.dns 8.8.8.8

Step 6. Now we need to change the IP addressing scheme from DHCP to static:

$ sudo nmcli connection modify ‘Wired connection 1’ IPv4.method manual

Step 7. Now turn off and then turn on the connection to apply changes:

$ sudo nmcli connection down ‘Wired connection 1.’


$ sudo nmcli connection up ‘Wired connection 1.’

All the above steps are shown in the below picture:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/8-8.png" data-lazy- height="535" src="data:image/svg xml,” width=”977″>

Now again, check the Gateway and IP with the command:

$ route -n


$ ip addr | grep enp0s3

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/9-5.png" data-lazy- height="381" src="data:image/svg xml,” width=”988″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/10-5.png" data-lazy- height="349" src="data:image/svg xml,” width=”1748″>

Step 2. In the left panel, you will see the network tab. Inside the network tab, click on the Settings icon as shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/11-3.png" data-lazy- height="344" src="data:image/svg xml,” width=”982″>

Step 3. A new window will open, displaying the already configured IP addresses, Gateway, DNS as shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/12-3.png" data-lazy- height="488" src="data:image/svg xml,” width=”634″>

Step 4. In the above window, select the IPv4 option from the top bar:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/13-3.png" data-lazy- height="482" src="data:image/svg xml,” width=”631″>

Step 5. Inside the IPv4 method segment, select the radio button corresponding to the manual option:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/14-3.png" data-lazy- height="493" src="data:image/svg xml,” width=”641″>

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


Netmask: 255.255.255.0


Gateway: 10.0.1.0


DNS: 8.8.8.8

We are leaving the Route segment row to be set automatically. See the reference picture below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/15-2.png" data-lazy- height="495" src="data:image/svg xml,” width=”639″>

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:

  1. Switch Off
  2. <img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/16-1.png" data-lazy- height="187" src="data:image/svg xml,” width=”981″>

  3. Switch On
  4. <img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/17-1.png" data-lazy- height="185" src="data:image/svg xml,” width=”983″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/18-1.png" data-lazy- height="193" src="data:image/svg xml,” width=”982″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/19-1.png" data-lazy- height="490" src="data:image/svg xml,” width=”637″>

Conclusion

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.

About the author

<img alt="Ali Imran Nagori" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/IMG_20201123_090644_2-150×150.jpg603d9a8f045cc.jpg" height="112" src="data:image/svg xml,” width=”112″>

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn


.