2010年12月25日星期六

Linux下检查系统开放的端口及服务

以下是在RHEL5中运行示例: [root@RHEL5 ~]# nmap -sT -O localhost
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2008-03-19 22:14 CST
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns_servers
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1670 closed ports

PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
23/tcp   open  telnet
25/tcp   open  smtp
111/tcp  open  rpcbind
609/tcp  open  npmp-trap
631/tcp  open  ipp
1521/tcp open  oracle
2601/tcp open  zebra
6103/tcp open  RETS-or-BackupExec

No exact OS matches for host (If you know what OS is running on it, see http://www.insecure.org/cgi-bin/nmap-submit.cgi).
TCP/IP fingerprint:
SInfo(V=4.11%P=i686-redhat-linux-gnu%D=3/19%Tm=47E11FD8%O=21%C=1)

Nmap finished: 1 IP address (1 host up) scanned in 9.886 seconds
或者使用netstat -anp命令来查看:
[root@RHEL5 ~]# netstat -anp | grep LISTEN
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      1894/hpiod         
tcp        0      0 0.0.0.0:609                 0.0.0.0:*                   LISTEN      1699/rpc.statd     
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1669/portmap       
tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN      29463/tnslsnr      
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      25248/vsftpd       
tcp        0      0 0.0.0.0:23                  0.0.0.0:*                   LISTEN      25182/xinetd       
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1911/cupsd         
tcp        0      0 0.0.0.0:6103                0.0.0.0:*                   LISTEN      29394/ora_d000_ora1
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1971/sendmail: acce
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      1899/python        
tcp        0      0 :::2601                     :::*                        LISTEN      3039/zebra         
tcp        0      0 :::22                       :::*                        LISTEN      1925/sshd

[root@RHEL5 ~]# lsof -n -i | grep LISTEN
COMMAND     PID      USER    FD      TYPE     DEVICE    SIZE  NODE    NAME
portmap     1669     rpc     4u      IPv4     4861            TCP     *:sunrpc (LISTEN)
rpc.statd   1699     root    7u      IPv4     4930            TCP     *:npmp-trap (LISTEN)
hpiod       1894     root    0u      IPv4     5369            TCP     127.0.0.1:2208 (LISTEN)
python      1899     root    4u      IPv4     5405            TCP     127.0.0.1:2207 (LISTEN)
cupsd       1911     root    2u      IPv4     791632          TCP     127.0.0.1:ipp (LISTEN)
sshd        1925     root    3u      IPv6     5461            TCP     *:ssh (LISTEN)
sendmail    1971     root    4u      IPv4     5627            TCP     127.0.0.1:smtp (LISTEN)
zebra       3039     root    10u     IPv6     9912            TCP     *:discp-client (LISTEN)
xinetd      25182    root    5u      IPv4     879173          TCP     *:telnet (LISTEN)
vsftpd      25248    root    3u      IPv4     879367          TCP     *:ftp (LISTEN)
oracle      29394    oracle  17u     IPv4     285612          TCP     *:rets (LISTEN)
tnslsnr     29463    oracle  7u      IPv4     286748          TCP     *:ncube-lm (LISTEN)

没有评论:

发表评论