商城首页欢迎来到中国正版软件门户

您的位置: 首页 > 文章列表 > 编程开发 > 如何通过ifconfig查看网络接口

如何通过ifconfig查看网络接口

  发布于2026-07-14 阅读(0)

扫一扫,手机访问

ifconfig 这个命令,在 Linux 系统里可是个老牌工具,专门用来查看和配置网络接口。简单说,你敲一下它,就能看到当前系统里所有网卡的状态、IP 地址、子网掩码这些关键信息。下面就是具体怎么操作,步骤其实很简单。

如何通过ifconfig查看网络接口

打开终端(Terminal),然后输入:

ifconfig

回车之后,系统会列出所有活动的网络接口及详细信息。输出内容大概长这样:

eth0: flags=4163mtu 1500
inet 192.168.1.100netmask 255.255.255.0broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe4e:66a1prefixlen 64scopeid 0x20
ether 08:00:27:4e:66:a1txqueuelen 1000(Ethernet)
RX packets 1003456bytes 123456789 (117.7 MiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 987654bytes 987654321 (941.5 MiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0

lo: flags=73mtu 65536
inet 127.0.0.1netmask 255.0.0.0
inet6 ::1prefixlen 128scopeid 0x10looptxqueuelen 1000(Local Loopback)
RX packets 12345bytes 123456 (120.4 KiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 12345bytes 123456 (120.4 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0

在这个例子里,有两个接口:eth0(以太网卡)和 lo(本地回环接口)。如果你想只看某一个接口的详情,比如只看 eth0,那就在命令后面加上接口名:

ifconfig eth0

需要留意的是,新一点的 Linux 发行版——比如 Ubuntu 18.04 及更高版本——已经不怎么推荐用 ifconfig 了,更建议用 ip 命令来替代。用 ip 查看网络接口的话,输入:

ip addr show

就这么简单。不过话说回来,很多老派运维还是习惯用 ifconfig,毕竟它够直观。但如果你用的是新系统,不妨试试 ip 命令,功能更强大,而且也是官方推荐的方向。

本文转载于:https://www.yisu.com/ask/44784598.html 如有侵犯,请联系zhengruancom@outlook.com删除。
免责声明:正软商城发布此文仅为传递信息,不代表正软商城认同其观点或证实其描述。

热门关注