How to get netstat on CentOS
CentOS contains only a little of the usual scope after the minimal installation, a number of system tools are missing, it seems at least, on closer inspection it becomes clear that they are only new commands, but the conventional tools can be installed afterwards.
One of these well-known commands is netstat, which is added as follows.
$ yum install -y net-tools
The whatprovides option can be used to determine which installation package contains the desired tool.
$ yum whatprovides netstat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.spreitzer.ch
* epel: mirror.spreitzer.ch
net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /bin/netstat
net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools
Repo : @base
Matched from:
Filename : /bin/netstat
net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools
Repo : @base
Matched from:
Filename : /usr/bin/netstat
net-tools is a collection of basic network programs. If the net-tools package is installed, the following commands are available on the host:
$ yum info net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name : net-tools
Arch : x86_64
Version: 2.0
Release: 0.24.20131004git.el7
Size: 918 k
Repo : installed
From repo : base
Summary : Basic networking tools
URL: http://sourceforge.net/projects/net-tools/
License : GPLv2+
Description : The net-tools package contains basic networking tools,
: including ifconfig, netstat, route, arp and others.
: Most of them are obsolete. For replacement check iproute package.
The net-tools restore the availability of the outdated Linux network commands, the following table shows the outdated Linux commands and the new replacement commands:
Outdated commands | New commands |
---|---|
Arp | ip n (ip neighbor) |
Ifconfig | ip a (ip addr), ip link |
iptunnel | ip tunnel |
Iwconfig | Iw |
nameif | ip link |
Netstat | ss -t (for netstat -t), ss -u (for netstat -u) ip route (for netstat -r) ip -s link (for netstat -i) ip maddr (for netstat -g) |
Route | ip r (ip route) |
ss – is the new utility to check sockets, ss
is used to dump socket statistics. It allows showing information similar to netstat.
Example of using ss instead of netstat:
$ ss -tuln4
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 127.0.0.1:10024 *:*
tcp LISTEN 0 100 127.0.0.1:10025 *:*
tcp LISTEN 0 100 *:587 *:*
tcp LISTEN 0 128 127.0.0.1:783 *:*
tcp LISTEN 0 100 *:465 *:*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 *:25 *:*
tcp LISTEN 0 128 127.0.0.1:8899 *:*
Likewise, a whois lookup can often provide useful information, for which whois must be installed:
$ yum -y install jwhois
$ Whois
jwhois version 4.0, Copyright (C) 1999-2007 Free Software Foundation, Inc.
This program is free software with ABSOLUTELY NO WARRANTY; you may
redistribute it under the terms of the GNU General Public License.
Usage: jwhoi[OPTIONS][QUERY]s
--version display version number and patch level
--help display this help
-v, --verbose verbose debug output
-c FILE, --config=FILE use FILE as configuration file
-h HOST, --host=HOST explicitly query HOST
-n, --no-redirect disable content redirection
-s, --no-whoisservers disable whois-servers.net service support
-a, --raw disable reformatting of the query
-i, --display-redirections display all redirects instead of hiding them
-p PORT, --port=PORT use port number PORT (in conjunction with HOST)
-r, --rwhois force an rwhois query to be made
--rwhois-display=DISPLAY sets the display option in rwhois queries
--rwhois-limit=LIMIT sets the maximum number of matches to return