Fedora 22: Setting a static IP address

Fedora 22: Setting a static IP address

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 192.168.1.148 netmask 255.255.255.0 broadcast 192.168.1.255
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 127.0.0.1 netmask 255.0.0.0
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.

UUID="e88f1292-1f87-4576-97aa-bb8b2be34bd3"
NM_CONTROLLED="yes"
HWADDR="D8:D3:85:AE:DD:4C"
BOOTPROTO="static"
DEVICE="em1"
ONBOOT="yes"
IPADDR=192.168.1.2
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
GATEWAY=192.168.1.1

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
nameserver 192.168.1.1
nameserver 8.8.8.8

Leave a Reply

5 Comments on "Fedora 22: Setting a static IP address"

Leave a Reply

Sort by:   newest | oldest | most voted
Llohr
Guest

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?

Janet Cruz
Guest

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
Guest

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

NM_CONTROLLED=”yes”

– should be –

NM_CONTROLLED=”no”

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.

wpDiscuz