在 Debian 里,“网络配置在哪里改”取决于 Debian 版本 和 你用的网络管理方式。下面按常见情况说明。
/etc/network/interfaces
示例:
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
应用配置:
systemctl restart networking
# 或
ifdown eth0 && ifup eth0
/etc/systemd/network/
示例文件:/etc/systemd/network/10-eth0.network
[Match]
Name=eth0
[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
DNS=8.8.8.8
启用:
systemctl enable --now systemd-networkd
/etc/NetworkManager/
连接配置:
/etc/NetworkManager/system-connections/
命令行修改:
nmcli connection modify eth0 ipv4.addresses 192.168.1.10/24
nmcli connection modify eth0 ipv4.gateway 192.168.1.1
nmcli connection modify eth0 ipv4.dns 8.8.8.8
nmcli connection up eth0
/etc/resolv.conf
/etc/systemd/resolved.conf
或
/etc/NetworkManager/conf.d/
ps aux | grep -E 'NetworkManager|systemd-networkd'
或:
cat /etc/network/interfaces
如果你告诉我:
cat /etc/debian_version)我可以直接给你一份可复制的配置文件。