Re: [SLUG] Port Forwarding And New Sys. Admins.

From: Kwan Lowe (kwan@digitalhermit.com)
Date: Mon Nov 29 2004 - 22:10:55 EST


Logan Tygart wrote:
[snip]
> A wonderful aspect of Linux, for most distributions anyway, is a list of
> all the services available for forwarding. This list is located in the
> file, aptly called, /etc/services.
>
> How can one determine ports from this fabulous file? The easiest way is
> by firing up your favorite terminal (xterm/konsole/gnome-terminal, etc.
> etc,) and employing the following command line example I used to help a
> new sys admin today, when perplexed as to what port MySQL listens:
>
> thelogan@bofh$ grep mysql /etc/services
> mysql 3306/tcp
> mysql 3306/udp
[snip]
>
> Hope this was useful,

This was a great post; sometimes these little tidbits can make a big
difference. A couple others that I often find useful:

[root@deepthought root]# netstat -tlnw
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:32774 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:32775 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:34443 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* L

netstat will show what ports are listening on your server. Using the
above example, 0.0.0.0:22 shows that port 22 is open. The 0.0.0.0 means
that it's listening on all IP addresses. If, for example, it showed
something like 127.0.0.1:25 it would mean that that particular service
is listening only on the private, localhost adapter and not on the
network itself. This is often the case with default sendmail
installations on new distributions. Grepping through /etc/services it
shows as "ssh".

You may sometimes need to associate a port with a service. To do this we
can use the fuser utility. Following from the above example:

[root@deepthought root]# fuser 22/tcp
22/tcp: 4203

You can alternatively do it like this:

[root@deepthought root]# fuser ssh/tcp
ssh/tcp: 4203

What this shows is that the process with PID 4203 is listening on port
22(ssh). You can then use the ps utility to get more info on the process:

[root@deepthought root]# ps -ef|grep 4203
root 4203 1 0 Nov19 ? 00:00:00 /usr/sbin/sshd

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:43:32 EDT