How to Configure Static IP Address and Set Hostname on Fedora 20

Share this Article :

This post will show the step to set the hostname and configure static IP address to the server. DHCP is not recommended if you plan to run this fedora 20 as a server. By default in Fedora 20, ifconfig command is not installed automatically. You should install net-tools package, it includes ifconfig and netstat.

ifconfig not installed by default :

[[email protected] ~]# ifconfig
-bash: ifconfig: command not found

1. Install net-tools, it will include ifconfig :

[[email protected] ~]# yum install net-tools -y
fedora/20/x86_64/metalink                                                    | 8.7 kB  00:00:01
fedora                                                                       | 3.8 kB  00:00:01
updates/20/x86_64/metalink                                                   | 5.0 kB  00:00:00
updates                                                                      | 4.9 kB  00:00:00
(1/4): fedora/20/x86_64/group_gz                                             | 394 kB  00:00:37
(2/4): updates/20/x86_64/group_gz                                            | 394 kB  00:00:43
(3/4): updates/20/x86_64/primary_db                                          | 8.8 MB  00:03:22
(4/4): fedora/20/x86_64/primary_db                                           |  18 MB  00:04:35
(1/2): updates/20/x86_64/pkgtags                                             | 1.0 MB  00:00:09
(2/2): updates/20/x86_64/updateinfo                                          | 920 kB  00:00:18
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.15.20131119git.fc20 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package             Arch             Version                                Repository        Size
====================================================================================================
Installing:
 net-tools           x86_64           2.0-0.15.20131119git.fc20              fedora           308 k

Transaction Summary
====================================================================================================
Install  1 Package

Total download size: 308 k
Installed size: 937 k
Downloading packages:
warning: /var/cache/yum/x86_64/20/fedora/packages/net-tools-2.0-0.15.20131119git.fc20.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 246110c1: NOKEY
Public key for net-tools-2.0-0.15.20131119git.fc20.x86_64.rpm is not installed
net-tools-2.0-0.15.20131119git.fc20.x86_64.rpm                               | 308 kB  00:00:10
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-20-x86_64
Importing GPG key 0x246110C1:
 Userid     : "Fedora (20) "
 Fingerprint: c7c9 a9c8 9153 f201 83ce 7cba 2eb1 61fa 2461 10c1
 Package    : fedora-release-20-1.noarch (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-20-x86_64
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.15.20131119git.fc20.x86_64                                       1/1
  Verifying  : net-tools-2.0-0.15.20131119git.fc20.x86_64                                       1/1

Installed:
  net-tools.x86_64 0:2.0-0.15.20131119git.fc20

Complete!

2. How to set the hostname :

[[email protected] ~]# vi /etc/hostname

Update to the preferred hostname :

 
fedora20.ehowstuff.local

3. Verify the interface name. In my case, the auto assigned interface for my ip address was ifcfg-ens32. It could be different from your server :

[[email protected] ~]# ls /etc/sysconfig/network-scripts/
ifcfg-ens32  ifdown-isdn    ifup-aliases  ifup-plip    ifup-wireless
ifcfg-lo     ifdown-post    ifup-bnep     ifup-plusb   init.ipv6-global
ifdown       ifdown-ppp     ifup-eth      ifup-post    network-functions
ifdown-bnep  ifdown-routes  ifup-ippp     ifup-ppp     network-functions-ipv6
ifdown-eth   ifdown-sit     ifup-ipv6     ifup-routes
ifdown-ippp  ifdown-tunnel  ifup-ipx      ifup-sit
ifdown-ipv6  ifup           ifup-isdn     ifup-tunnel

4. Configure static IP address :

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32

The original configuration file :

TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="ens32"
UUID="8f3bcce9-631f-4874-a642-c78b2badb94d"
ONBOOT="yes"
HWADDR="00:0C:29:8C:7B:FE"
PEERDNS="yes"
PEERROUTES="yes"

Change to below :

TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="ens32"
UUID="8f3bcce9-631f-4874-a642-c78b2badb94d"
ONBOOT="yes"
HWADDR="00:0C:29:8C:7B:FE"
PEERDNS="yes"
PEERROUTES="yes"
IPADDR="192.168.0.20"
NETMASK="255.255.0.0"
GATEWAY="192.168.0.1"

5. Disable network manager and use the simple network service :

[[email protected] ~]# systemctl disable NetworkManager.service
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
[[email protected] ~]# systemctl start network.service
[[email protected] ~]# chkconfig network on

6. Reboot server :

[[email protected] ~]# reboot

7. Once rebooted, verify the updated hostname and ip address :

[[email protected] ~]# hostname
fedora20.ehowstuff.local
[[email protected] ~]# ifconfig
ens32: flags=4163  mtu 1500
        inet 192.168.0.20  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::20c:29ff:fe8c:7bfe  prefixlen 64  scopeid 0x20
        ether 00:0c:29:8c:7b:fe  txqueuelen 1000  (Ethernet)
        RX packets 335  bytes 34848 (34.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 322  bytes 28792 (28.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Leave a Reply