在 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
ip -4 addr
或只看某个网卡(如 eth0):
ip -4 addr show eth0
hostname 命令hostname -I
输出示例:
192.168.1.100
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。