温馨提示×

debian ifconfig如何开启

小樊
44
2026-09-06 16:09:55
栏目: 智能运维

在 Debian 中,ifconfig 默认可能 没有安装,而且在新版 Debian 中更推荐使用 ip 命令。下面分情况说明:


一、ifconfig 命令找不到(未安装)

1. 安装 net-tools

sudo apt update
sudo apt install net-tools

安装完成后即可使用:

ifconfig

二、使用 ifconfig 开启网卡

查看网卡名称

ifconfig -a

或

ip addr

开启网卡(以 eth0 为例)

sudo ifconfig eth0 up

关闭网卡

sudo ifconfig eth0 down

配置 IP 并开启

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up

三、Debian 推荐方式(ip 命令)

开启网卡

sudo ip link set eth0 up

配置 IP

sudo ip addr add 192.168.1.100/24 dev eth0

四、开机自动启用网卡(Debian 11/12)

编辑:

sudo nano /etc/network/interfaces

示例(DHCP):

auto eth0
iface eth0 inet dhcp

或静态 IP:

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1

重启网络:

sudo systemctl restart networking

如果你告诉我 Debian 版本 和 网卡名称,我可以给你更精确的命令。

0 踩