2019-07-12 10:24:51 1366浏览
今天千锋扣丁学堂Linux培训老师给大家分享一篇关于Linux运维使用ss命令代替netstat的详细介绍,首先在运维和管理Linux服务器的时候,我们最常用的一个命令就是netstat,我常用这个命令来查看当前服务器上有哪些进程正在侦听端口,主要用来诊断网络服务的工作状态。
This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for netstat -i is ip -s link. Replacement for netstat -g is ip maddr.
netstat -npl
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 655/systemd-resolve tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 890/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 30790/cupsd tcp 0 0 0.0.0.0:18025 0.0.0.0:* LISTEN 890/sshd tcp6 0 0 :::22 :::* LISTEN 890/sshd tcp6 0 0 ::1:631 :::* LISTEN 30790/cupsd tcp6 0 0 :::9090 :::* LISTEN 15415/./prometheus tcp6 0 0 :::18025 :::* LISTEN 890/sshd udp 0 0 127.0.0.53:53 0.0.0.0:* 655/systemd-resolve udp 0 0 0.0.0.0:631 0.0.0.0:* 30792/cups-browsed udp 0 0 0.0.0.0:5353 0.0.0.0:* 757/avahi-daemon: r udp 0 0 0.0.0.0:42360 0.0.0.0:* 757/avahi-daemon: r udp6 0 0 :::58232 :::* 757/avahi-daemon: r udp6 0 0 :::5353 :::* 757/avahi-daemon: r Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 35116 1304/gnome-session- @/tmp/.ICE-unix/1304 unix 2 [ ACC ] SEQPACKET LISTENING 1448 1/init /run/udev/control unix 2 [ ACC ] STREAM LISTENING 34277 1270/systemd /run/user/1000/systemd/private unix 2 [ ACC ] STREAM LISTENING 34282 1270/systemd /run/user/1000/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 33510 1270/systemd /run/user/1000/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 33511 1270/systemd /run/user/1000/pulse/native unix 2 [ ACC ] STREAM LISTENING 33512 1270/systemd /run/user/1000/gnupg/S.gpg-agent.extra
ss -atlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.53%lo:domain 0.0.0.0:* users:(("systemd-resolve",pid=655,fd=13)) LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:* users:(("sshd",pid=890,fd=5)) LISTEN 0 5 127.0.0.1:ipp 0.0.0.0:* users:(("cupsd",pid=30790,fd=7)) LISTEN 0 128 0.0.0.0:18025 0.0.0.0:* users:(("sshd",pid=890,fd=3)) LISTEN 0 128 [::]:ssh [::]:* users:(("sshd",pid=890,fd=6)) LISTEN 0 5 [::1]:ipp [::]:* users:(("cupsd",pid=30790,fd=6)) LISTEN 0 128 *:9090 *:* users:(("prometheus",pid=15415,fd=3)) LISTEN 0 128 [::]:18025 [::]:* users:(("sshd",pid=890,fd=4))
Luk Claes and me, as the current maintainers of net-tools, we’ve been thinking about it’s future. Net-tools has been a core part of Debian and any other linux based distro for many years, but it’s showing its age. It doesnt support many of the modern features of the linux kernel, the interface is far from optimal and difficult to use in automatisation, and also, it hasn’t got much love in the last years. On the other side, the iproute suite, introduced around the 2.2 kernel line, has both a much better and consistent interface, is more powerful, and is almost ten years old, so nobody would say it’s untested. Hence, our plans are to replace net-tools completely with iproute, maybe leading the route for other distributions to follow. Of course, most people and tools use and remember the venerable old interface, so the first step would be to write wrappers, trying to be compatible with net-tools. At the same time, we believe that most packages using net-tools should be patched to use iproute instead, while others can continue using the wrappers for some time. The ifupdown package is obviously the first candidate, but it seems that a version using iproute has been available in experimental since 2007.
【关注微信公众号获取更多学习资料】 【扫码进入HTML5前端开发VIP免费公开课】