【主机】查看服务器端口状态

简介: 早上查看邮件的时候 收到 oracle 1521 不能访问的报警邮件。立即登录服务器,查看 lsnrctl status 一切正常!同事和网络工程师沟通了,发现是凌晨ACL 推演导致暂时不可访问。
早上查看邮件的时候 收到 oracle 1521 不能访问的报警邮件。立即登录服务器,查看 lsnrctl status 一切正常!同事和网络工程师沟通了,发现是凌晨ACL 推演导致暂时不可访问。
这里总结几种查看服务器上端口的状态的方法:
1 netstat -an 查看网络端口 
oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>netstat -antp       
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
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      -                   
tcp        0      0 0.0.0.0:111         0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:784         0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:1521      0.0.0.0:*                   LISTEN      21883/tnslsnr       
tcp        0      0 127.0.0.1:631       0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:25        0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:38173       0.0.0.0:*                   LISTEN      5902/ora_d000_orcl  
tcp        0      0 127.0.0.1:2207      0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:25045     127.0.0.1:1521              ESTABLISHED 5880/ora_pmon_orcl  
tcp        0      0 127.0.0.1:1521      127.0.0.1:25045             ESTABLISHED 21883/tnslsnr       
tcp        0      0 :::22               :::*                        LISTEN      -                   
tcp        0   1036 ::ffff:10.250.7.230:22 ::ffff:10.1.165.1:51312  ESTABLISHED -   
2 lsof -i :port,使用lsof -i :port就能看见所指定端口运行的程序,同时还有当前连接。 
oracle@dba-host1:/home/oracle>lsof -i :1521
COMMAND   PID   USER   FD   TYPE    DEVICE SIZE NODE NAME
oracle    300 oracle   14u  IPv4 380560725       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32845 (ESTABLISHED)
oracle    302 oracle   14u  IPv4 380560734       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32846 (ESTABLISHED)
oracle    304 oracle   14u  IPv4 380560743       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32847 (ESTABLISHED)
oracle    306 oracle   14u  IPv4 380560752       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32848 (ESTABLISHED)
oracle    575 oracle   14u  IPv4 386960754       TCP dba-host1.hz.ali.com:1521->10.1.170.195:55487 (ESTABLISHED)
oracle    952 oracle   14u  IPv4 361820559       TCP dba-host1.hz.ali.com:1521->10.250.2.14:54674 (ESTABLISHED)
oracle   1445 oracle   14u  IPv4 387183135       TCP dba-host1.hz.ali.com:1521->10.250.3.111:15845 (ESTABLISHED)
oracle   1548 oracle   14u  IPv4 386924530       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33970 (ESTABLISHED)
oracle   1550 oracle   14u  IPv4 386924539       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33971 (ESTABLISHED)
oracle   1650 oracle   14u  IPv4 385984708       TCP dba-host1.hz.ali.com:1521->10.1.170.148:1717 (ESTABLISHED)
oracle   2036 oracle   14u  IPv4 385310535       TCP dba-host1.hz.ali.com:1521->10.1.170.143:44647 (ESTABLISHED)
oracle   2734 oracle   14u  IPv4 379270888       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2837 (ESTABLISHED)
oracle   2736 oracle   14u  IPv4 379270897       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2849 (ESTABLISHED)
oracle   2738 oracle   14u  IPv4 379270907       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2855 (ESTABLISHED)
oracle   2740 oracle   14u  IPv4 379270916       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2856 (ESTABLISHED)
oracle   2742 oracle   14u  IPv4 379270925       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2857 (ESTABLISHED)
oracle   2744 oracle   14u  IPv4 379270934       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2859 (ESTABLISHED)
oracle   2746 oracle   14u  IPv4 379270943       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2860 (ESTABLISHED)
oracle   2748 oracle   14u  IPv4 379270952       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2861 (ESTABLISHED)
oracle   2828 oracle   14u  IPv4 379271084       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2875 (ESTABLISHED)
oracle   2830 oracle   14u  IPv4 379271093       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2877 (ESTABLISHED)
oracle   2832 oracle   14u  IPv4 379271102       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2878 (ESTABLISHED)
oracle   2834 oracle   14u  IPv4 379271111       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2880 (ESTABLISHED)
oracle   2836 oracle   14u  IPv4 379271120       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2881 (ESTABLISHED)
oracle   2838 oracle   14u  IPv4 379271129       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2882 (ESTABLISHED)
oracle   2840 oracle   14u  IPv4 379271138       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2884 (ESTABLISHED)
oracle   2842 oracle   14u  IPv4 379271147       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2885 (ESTABLISHED)
oracle   2856 oracle   14u  IPv4 379271211       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2895 (ESTABLISHED)
oracle   2858 oracle   14u  IPv4 379271220       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2896 (ESTABLISHED)
oracle   2870 oracle   14u  IPv4 379271274       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2905 (ESTABLISHED)
oracle   2872 oracle   14u  IPv4 379271283       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2906 (ESTABLISHED)
oracle   3456 oracle   14u  IPv4 355696647       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32818 (ESTABLISHED)
oracle   3460 oracle   14u  IPv4 355696666       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32821 (ESTABLISHED)
oracle   3464 oracle   14u  IPv4 355696685       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32823 (ESTABLISHED)
oracle   3466 oracle   14u  IPv4 355696694       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32824 (ESTABLISHED)
oracle   3475 oracle   14u  IPv4 355696731       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32828 (ESTABLISHED)
oracle   3543 oracle   14u  IPv4 355696974       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33015 (ESTABLISHED)
oracle   3545 oracle   14u  IPv4 355696984       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33016 (ESTABLISHED)
oracle   3547 oracle   14u  IPv4 355696993       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33017 (ESTABLISHED)
oracle   3549 oracle   14u  IPv4 355697002       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33018 (ESTABLISHED)
oracle   3551 oracle   14u  IPv4 355697012       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33019 (ESTABLISHED)
oracle   3553 oracle   14u  IPv4 355697021       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33020 (ESTABLISHED)
oracle   3555 oracle   14u  IPv4 355697030       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33021 (ESTABLISHED)
oracle   3557 oracle   14u  IPv4 355697039       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33022 (ESTABLISHED)
oracle   3559 oracle   14u  IPv4 355697048       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33023 (ESTABLISHED)
oracle   3561 oracle   14u  IPv4 355697057       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33024 (ESTABLISHED)
oracle   3742 oracle   14u  IPv4 387787027       TCP dba-host1.hz.ali.com:1521->10.250.3.111:39453 (ESTABLISHED)
oracle   3915 oracle   14u  IPv4 332853968       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49232 (ESTABLISHED)
oracle   3917 oracle   14u  IPv4 332853977       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49233 (ESTABLISHED)
oracle   3919 oracle   14u  IPv4 332853986       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49234 (ESTABLISHED)
oracle   3921 oracle   14u  IPv4 332853995       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49235 (ESTABLISHED)
oracle   3923 oracle   14u  IPv4 332854004       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49236 (ESTABLISHED)
oracle   3925 oracle   14u  IPv4 332854014       TCP dba-

3 nmap 端口扫描
oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>nmap 10.1.157.42
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-08-18 21:31 CST
Interesting ports on 10.1.157.42:
Not shown: 1670 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
952/tcp  open  unknown
1521/tcp open  oracle
5801/tcp open  vnc-http-1
5802/tcp open  vnc-http-2
5901/tcp open  vnc-1
5902/tcp open  vnc-2
6001/tcp open  X11:1
6002/tcp open  X11:2

4 文件/etc/services显示的各个服务的端口号;
oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>cat /etc/services | more
# /etc/services:
# $Id: services,v 1.42 2006/02/23 13:09:23 pknirsch Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
# are included, only the more common ones.
#
# The latest IANA port assignments can be gotten from
#       http://www.iana.org/assignments/port-numbers
# The Well Known Ports are those from 0 through 1023.
# The Registered Ports are those from 1024 through 49151
# The Dynamic and/or Private Ports are those from 49152 through 65535
#
# Each line describes one service, and is of the form.:
# service-name  port/protocol  [aliases ...]   [# comment]

tcpmux          1/tcp                           # TCP port service multiplexer
tcpmux          1/udp                           # TCP port service multiplexer
rje             5/tcp                           # Remote Job Entry
rje             5/udp                           # Remote Job Entry
echo            7/tcp
echo            7/udp
discard         9/tcp           sink null
discard         9/udp           sink null
systat          11/tcp          users
systat          11/udp          users
daytime         13/tcp
daytime         13/udp
qotd            17/tcp          quote
qotd            17/udp          quote
msp             18/tcp                          # message send protocol
--More--
使用netstat -a 可以看见所有的端口号,这个自己测试啦。。
目录
相关文章
|
3月前
|
运维 安全 数据库
cmd中使用telnet检测远程的ip及端口是否处于监听状态
cmd中使用telnet检测远程的ip及端口是否处于监听状态
30 1
|
4月前
|
网络安全 Windows
Telnet - 访问8080端口并发送数据
Telnet - 访问8080端口并发送数据
74 0
|
8月前
|
缓存 网络协议 Linux
连接一个 IP 不存在的主机时,握手过程是怎样的?
连接一个 IP 不存在的主机时,握手过程是怎样的?
45 0
|
网络协议
服务器端口是什么?了解服务器端口的作用和原理
随着现在计算机网络技术的不断发展,原来物理上的接口(如键盘、鼠标、网卡、显示卡等输入/输出接口)已经不能全面满足网络通信的要求了,因此TCP/IP协议作为网络通信的标准协议就解决了这个通信的难题。在TCP/IP协议中引入”Socket(套接字)”应用程序接口,并将TCP/IP协议集成到计算机操作系统的内核中。 如此一来就相当于在操作系统中引入了一套全新的输入/输出接口技术,因此每一台服务器通过不同的端口都提供不同的服务,所以很多时候一台服务器同时可以是Web服务器,也可以是FTP服务器,还可以是邮件服务器等。 服务器端口是什么意思?
1778 0
loadunner使用socket协议来实现多客户端连接同一服务器脚本(使用到IP欺骗技术)
第一部分: #include "lrs.h" vuser_init(){ lrs_startup(257); return 0;}   第二部分: Action(){ char *ReturnValue_Remote; char *ReturnPort_Remote; char *ReturnValue_Local; char *ReturnPort_Local; char *AcutalBuffer; int BufferSize; char *ip; //编写获取LR分配的Vuser IP函数,将IP保存在ip变量中。
744 0
|
测试技术
loadrunner使用socket协议来实现客户端对服务器产生压力实例。(通过发送心跳包,达到连接多个客户端的目的)
#include "lrs.h" vuser_init(){ char *ip; int handler; //编写获取LR分配的Vuser IP函数,将IP保存在ip变量中。 ip=lr_get_vuser_ip(); if(ip) lr_vuser_status_message("the ip address is %s:",ip); else lr_vuser_status_message("IP spooler disabled"); //输出获取到lr分配的ip值。
1071 0