`
cakin24
  • 浏览: 1331899 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

服务与端口

阅读更多
一 端口是什么
如果把IP地址比作一间房子,端口就是出入这间房子的门。真正的房子只有几个门,但是一个IP地址端口可以有65536个。
 
二 关于端口


 
 
三 端口与服务的对应
/etc/services
 
四 查询系统中开启的服务
netstat -tlunp
-t:列出tcp数据
-u:列出udp数据
-l:列出正在监听的网络服务
-n:用端口号来显示服务,而不是用服务名
-p:列出该服务的进程ID
该命令会列出系统中所有的已经启动的服务。
 
五 实战
[root@localhost ~]# netstat -tlun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
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
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 0.0.0.0:55516 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:9456 0.0.0.0:*
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp6 0 0 :::57782 :::*
[root@localhost ~]# netstat -tlunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1939/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1182/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1177/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2025/master
tcp6 0 0 :::22 :::* LISTEN 1182/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1177/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 2025/master
udp 0 0 0.0.0.0:55516 0.0.0.0:* 548/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 548/avahi-daemon: r
udp 0 0 0.0.0.0:9456 0.0.0.0:* 5060/dhclient
udp 0 0 192.168.122.1:53 0.0.0.0:* 1939/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 1939/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 5060/dhclient
udp6 0 0 :::57782 :::*
[root@localhost ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
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 192.168.0.106:22 192.168.0.101:38799 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 0.0.0.0:55516 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:9456 0.0.0.0:*
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp6 0 0 :::57782 :::*
raw6 0 0 :::58 :::*
  • 大小: 66.2 KB
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics