2019-07-12 10:24:51 2516瀏覽
今天千鋒扣丁學(xué)堂Linux培訓(xùn)老師給大家分享一篇關(guān)于Linux運(yùn)維使用ss命令代替netstat的詳細(xì)介紹,首先在運(yùn)維和管理Linux服務(wù)器的時(shí)候,我們最常用的一個(gè)命令就是netstat,我常用這個(gè)命令來查看當(dāng)前服務(wù)器上有哪些進(jìn)程正在偵聽端口,主要用來診斷網(wǎng)絡(luò)服務(wù)的工作狀態(tài)。
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.
【關(guān)注微信公眾號(hào)獲取更多學(xué)習(xí)資料】 【掃碼進(jìn)入HTML5前端開發(fā)VIP免費(fèi)公開課】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>