在 Debian 里看 IP 地址,常见有几种方式(取决于系统版本和是否安装了相关工具):
ifconfig(传统方式)ifconfig
command not found,说明没装 net-tools:sudo apt update
sudo apt install net-tools
inet 那一栏,例如:inet 192.168.1.100 netmask 255.255.255.0
那个 192.168.1.100 就是 IP。
ip 命令(推荐,Debian 默认就有)ip addr
或简写:
ip a
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
192.168.1.100 就是 IPv4 地址。
只看 IPv4:
ip -4 addr
ip addr show eth0
或
ifconfig eth0
curl ifconfig.me
或
curl ipinfo.io/ip
如果你是在 新装 Debian 12,ifconfig 默认是没有的,直接用 ip a 最方便。
需要我帮你判断你当前系统是哪种情况吗?