1. ip addr
ip addr 或者 ip addr show

输出包含了网络接口的名称、状态、MTU(Maximum Transmission Unit)、链路层地址(如MAC地址)、IPv4和IPv6地址等信息。
2. 只需要 ip地址
ipV4
ip addr | grep inet

ipV6

3.查看端口
ss -tuln
参数说明:
-
-t
表示显示TCP端口 -
-u
表示显示UDP端口 -
-l
表示显示监听状态的端口 -
-n
表示不解析服务名称(使用端口号显示)
如果你想要看到哪些程序正在监听或使用哪些端口,可以去掉-n
参数:
ss -tul

使用netstat
查看端口:
netstat -tuln

参数与ss
命令相同
如果你想要查看特定端口是否被使用,可以使用grep
命令筛选:
ss -tuln | grep :80
