How to Set a Static IP for Your Fedora VM: A Step-by-Step Guide


An important and helpful step before diving into any project is to assign a static IP to your VM.
This will ensure that you don’t need to check the server IP for logging in via SSH as well as don’t need frequent modifications inside automation scripts/Spring Boot projects.
1. Log in to Your Fedora VM and Discover Your Current IP Address
Login to the VM using the “Virtual Machine Manager”.
To set up Virtual Machine Manager, follow this guide from my ongoing series: KVM setup on Fedora. Once the setup is complete, search for “Virtual Machine Manager” in your system’s search bar. Open the app, “run” the VM by selecting your server, and click on “Open”. This will launch your Fedora QEMU/KVM console.
It’ll look something like the below snapshot:
After loggin-in, run the below command on either of the console.
ip a | grep inet
#SAMPLE OUTPUT
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host noprefixroute
inet 192.168.124.54/24 brd 192.168.124.255 scope global noprefixroute enp1s0
inet6 fe80::5054:ff:fe57:17c5/64 scope link noprefixroute
from the sample output, you can easily get your server IP, here it is 192.168.124.54.
2. Determine Your Active Network Interface
Before making the changes, we’ll find the active device:
root@localhost:~# nmcli connection show
NAME UUID TYPE DEVICE
enp1s0 19d67abb-cd75-377e-a963-eb9f13582a50 ethernet enp1s0
From the above sample output, we can conclude the device to be “enp1s0” and this will come handy in our next step.
3. Set Up a Static IP Profile for Your Fedora VM
Create/edit configuration file bu using below command. (From the output sample, make sure that the IPv4 configs matches).
vi /etc/NetworkManager/system-connections/enp1s0.nmconnection
Make sure the configuration for IPv4 matches with the below confiig:
[connection]
id=enp1s0
uuid=19d67abb-cd75-377e-a963-eb9f13582a50
type=ethernet
autoconnect-priority=-999
interface-name=enp1s0
timestamp=1742568216
[ethernet]
[ipv4]
address1=192.168.124.54/24,192.168.124.1
dns=8.8.8.8;8.8.4.4;
method=manual
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
After verfying the above setup and making changes, run the below command.
chmod 600 /etc/NetworkManager/system-connections/enp1s0.nmconnection
4. Save and Apply Your Network Configuration Changes
After making the above changes, run the below command or simply reboot the VM to save the config.
nmcli connection down enp1s0 && nmcli connection up enp1s0
5. Verify Your Static IP Configuration
Run the below commands
ip a show enp1s0
#You should see your static IP in the output
ping 8.8.8.8 # check internet
ping google.com # check DNS
Happy Learning !!!
Feel free to drop a comment in-case you face issues with it, I’ll try to recreate the error and share the steps to resolve it.
Subscribe to my newsletter
Read articles from Shreyas S directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
