在 Debian 系统中,查看 IP 地址常用以下几种方式:
ifconfig(传统方式)如果系统已安装 net-tools:
ifconfig
查看某个网卡(如 eth0):
ifconfig eth0
IP 地址通常显示在 inet 一行(IPv4),inet6 是 IPv6。
如果提示 command not found,先安装:
sudo apt update
sudo apt install net-tools
ip 命令(推荐)Debian 默认已支持:
ip addr
或简写:
ip a
查看某个网卡:
ip addr show eth0
hostname -I
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
其中 192.168.1.100 就是本机 IP。
如果你是在 Debian 12+ 或最小化安装环境中,建议直接使用 ip a,ifconfig 已逐渐被淘汰。