在 Debian 中,ifconfig 本身不直接显示子网掩码(subnet mask)的 CIDR 形式(如 /24),但可以通过它看到子网掩码(netmask),从而判断子网。
ifconfig
或只看某个网卡(如 eth0):
ifconfig eth0
示例输出:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
这里的:
192.168.1.10255.255.255.0192.168.1.255常见对应关系:
255.255.255.0 → /24(子网:192.168.1.0/24)255.255.0.0 → /16255.0.0.0 → /8255.255.255.128 → /25所以:
192.168.1.10 / 255.255.255.0
说明你在 192.168.1.0/24 子网下。
Debian 新版本默认可能没装 ifconfig,推荐用:
ip addr
或
ip -br addr
示例:
inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0
这里 /24 直接就是子网。
ip route
可以看到:
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10
✅ 总结:
ifconfig 看 netmaskip addr 看 CIDR(/24)如果你愿意,可以贴出你的 ifconfig 输出,我帮你算具体子网。