Fedora 22: Setting a static IP address

Fedora Bash
This is a quick tutorial on how to set a static IP address using the terminal within Fedora 22.

Disable Network Manager

1. First stop and disable the gnome network manager from running on boot.

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

2. Now start and enable the network service to run on boot.

systemctl restart network.service
systemctl enable network.service

Set the Static Address

1. Check which interface(s) you want to set as static.

[[email protected] ~]# ifconfig
em1: flags=4163 mtu 1500
inet netmask broadcast
inet6 fe80::dad3:85ff:feae:dd4c prefixlen 64 scopeid 0x20 ether d8:d3:85:ae:dd:4c txqueuelen 1000 (Ethernet)
RX packets 929 bytes 90374 (88.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1010 bytes 130252 (127.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19

lo: flags=73mtu 16436
inet netmask
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 32 bytes 3210 (3.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 3210 (3.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2. Next edit the config file for the required interface.

vi /etc/sysconfig/network-scripts/ifcfg-em1

3. Edit the config file to look similar to the following.

Change the BOOTPROTO from “dhcp” to “static”. Also adding IPADDR, NETMASK, BROADCAST and NETWORK variables and make sure ONBOOT is set to yes.


Apply the Settings

Restart the network service to apply the settings.

systemctl restart network.service

Configure DNS

Make sure the correct DNS servers are configured to allow Fedora to resolve domains.

vi /etc/resolv.conf
  • Llohr

    I did all of this, and ended up with a non-functional connection–resolv.conf was impossible to edit. I ended up re-disabling network.service, enabling and restarting NetworkManager.service, and editing the DNS servers through the GUI. Looks like Network Manager handles static IPs just fine. Why shut it off?

    • This was the best method at time of writing for static addresses on CLI. However that may of changed since. I was looking in to writing an updated tutorial for the latest version of fedora using network manager when I have the time. But yeah if you have a GUI its easier to use that i reckon 🙂

      • Llohr

        These days, unless you disable dhcpcd, you’ve just gotta edit /etc/wpa_supplicant/wpa_supplicant.conf.

        Of course, all those other files are still there, and still appear to do what they did before. If you’re observant, you’ll follow the trail of breadcrumbs through the various config files for a while, and end up at dhcpcd.conf. Sadly that doesn’t seem to get you to wpa_supplicant.conf, but that’s the Linux way.

        Once, when attempting to change some simple bash setting or another, I followed such a trail. It began in the file everyone said should be edited, but which itself was entirely commented out, except for a single line which sourced another file.

        The trail led through many such files, and ended when I reached a file where there was no single uncommented line, they were all comments.

    • Janet Cruz

      I have Fedora 25 and using the NetworkManager GUI by itself would not change the settings, so I followed the instructions above and also got errors when I did

      systemctl enable network.service

      nonetheless I edited the ifcfg-em1 file and tried restarting the network.service but nothing worked. I had to restart the computer and when it came back up I did

      systemctl enable NetworkManager.service

      systemctl restart NetworkManager.service
      and opened the NetworkManager GUI and to my surprise all the settings were what I had changed them to.

  • WillG

    The above instructions work, with a minor correction and one addition. First, in /etc/sysconfig/network-scripts/ifcfg-


    – should be –


    And you need to unlink resolv.conf:

    # unlink /etc/resolv.conf

    Then you should be able to create a new resolv.conf and save. Everything should work by following the rest of the instructions above.