about 2 years ago

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

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.

    [root@server ~]# 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.

    # 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
    

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.

# vim /etc/resolv.conf
nameserver 192.168.1.1
nameserver 8.8.8.8
← DevOps Tools diff →
 
comments powered by Disqus