温馨提示×

如何查看Debian IP地址

小樊
38
2026-07-10 07:21:54
栏目: 智能运维

在 Debian 系统中,可以通过以下几种常用方式查看 IP 地址:


方法一:使用 ip 命令(推荐)

这是现代 Linux 系统推荐的方式。

ip addr

或简写:

ip a

输出示例:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

其中 inet 后面的就是 IPv4 地址。


方法二:使用 ifconfig(旧方式)

如果系统已安装 net-tools

ifconfig

若未安装:

sudo apt update
sudo apt install net-tools

方法三:只查看 IPv4 地址

ip -4 addr

或只看某个网卡(如 eth0):

ip -4 addr show eth0

方法四:使用 hostname 命令

hostname -I

输出示例:

192.168.1.100

方法五:查看路由信息(可看到主 IP)

ip route

示例:

default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100

src 后面的就是本机 IP。


常见网卡名称说明

  • eth0:传统有线网卡
  • ens33 / enp0s3:可预测网卡命名
  • wlan0:无线网卡

如果你是在 服务器没有图形界面连接了多个网卡,可以告诉我具体场景,我可以帮你更精确判断该用哪个 IP。

0