EmbLogic's Blog

How to set static ip in Fedora

Below is the method to give your machine a static Ip for the fedora.[Next post will contain the method to provide Static ip to Raspberry Pi running raspbian]

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.

# 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 0×20 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 0×10
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.

vim /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

Exit the editor by pressing ‘:wq’ and enter.

4. Restart the network service to apply the settings.

systemctl restart network.service

source : https://fedoraproject.org/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>