How to Install ifconfig and netstat on RHEL 7.0/CentOS 7.0/Oracle Linux 7

Introduction:

ifconfig and netstat are two popular network tools that are commonly used in Linux-based operating systems. These tools can be used to display information about network interfaces and network connections respectively. However, ifconfig and netstat are not installed by default on some Linux distributions, including RHEL 7.0, CentOS 7.0, and Oracle Linux 7.

# ifconfig
-bash: ifconfig: command not found

In this guide, we will show you how to install ifconfig and netstat on RHEL 7.0/CentOS 7.0/Oracle Linux 7.

Step 1: Enable EPEL repository

The first step is to enable the EPEL (Extra Packages for Enterprise Linux) repository. This repository contains additional software packages that are not included in the base RHEL/CentOS/Oracle Linux distribution. To enable the EPEL repository, run the following command:

sudo yum install epel-release

Step 2: Install net-tools package

After enabling the EPEL repository, you can install the net-tools package, which includes both ifconfig and netstat, by running the following command:

sudo yum install net-tools
# yum install net-tools -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.biz.net.id
 * extras: mirror.smartmedia.net.id
 * updates: centos.biz.net.id
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package              Arch              Version                               Repository       Size
====================================================================================================
Installing:
 net-tools            x86_64            2.0-0.17.20131004git.el7              base            304 k

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

Total download size: 304 k
Installed size: 917 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.17.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for net-tools-2.0-0.17.20131004git.el7.x86_64.rpm is not installed
net-tools-2.0-0.17.20131004git.el7.x86_64.rpm                                | 304 kB  00:00:10
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key)"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-0.1406.el7.centos.2.3.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.17.20131004git.el7.x86_64                                        1/1
  Verifying  : net-tools-2.0-0.17.20131004git.el7.x86_64                                        1/1

Installed:
  net-tools.x86_64 0:2.0-0.17.20131004git.el7

Complete!

Step 3: Verify installation

To verify that ifconfig and netstat have been installed successfully, you can run the following commands:

ifconfig
netstat -a

These commands should display information about network interfaces and network connections respectively. For example:

See also  How to Fix "Initializing ldap...failed" Zimbra Installation on CentOS 6.2 x86_64

1. ifconfig command:

# ifconfig
ens160: flags=4163  mtu 1500
        inet 192.168.0.18  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20c:29ff:feba:3efe  prefixlen 64  scopeid 0x20
        ether 00:0c:29:ba:3e:fe  txqueuelen 1000  (Ethernet)
        RX packets 10357  bytes 9459534 (9.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8239  bytes 2341646 (2.2 MiB)
        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

2. netstat command:

# netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1919/master
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1318/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1919/master
tcp6       0      0 :::22                   :::*                    LISTEN      1318/sshd
udp        0      0 0.0.0.0:47445           0.0.0.0:*                           572/avahi-daemon: r
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           572/avahi-daemon: r

Commands Mentioned:

  • yum – package manager for RHEL/CentOS/Oracle Linux
  • sudo – execute a command with administrative privileges
  • epel-release – repository package for EPEL
  • net-tools – package that includes ifconfig and netstat
See also  How to Install CentOS 5.7 Server Part 2

Conclusion:

In this guide, we have shown you how to install ifconfig and netstat on RHEL 7.0/CentOS 7.0/Oracle Linux 7. By enabling the EPEL repository and installing the net-tools package, you can use ifconfig and netstat to display information about network interfaces and network connections respectively.

Comments

1 Comment

Leave a Reply

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