温馨提示×

debian ifconfig怎么看ip

小樊
49
2026-09-15 17:33:21
栏目: 智能运维

在 Debian 里看 IP 地址,常见有几种方式(取决于系统版本和是否安装了相关工具):


1. 用 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。


2. 用 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

3. 只看某个网卡

ip addr show eth0

ifconfig eth0

4. 看公网 IP(需联网)

curl ifconfig.me

curl ipinfo.io/ip

如果你是在 新装 Debian 12ifconfig 默认是没有的,直接用 ip a 最方便。

需要我帮你判断你当前系统是哪种情况吗?

0