你提到的 “sedebian” 可能是笔误,常见的是 Debian 或 Raspbian / Raspberry Pi OS(基于 Debian)。下面我按 Debian 系统网络配置 来说明,适用于服务器、桌面或虚拟机环境。
Debian 10+ 默认使用:
/etc/network/interfaces(传统方式,服务器常用)sudo nano /etc/network/interfaces
内容示例:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
eth0可能是ens33、enp0s3,用ip a查看
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
sudo systemctl restart networking
或
sudo ifdown eth0 && sudo ifup eth0
如果你用的是 Debian 12 + cloud image,可能用 Netplan:
sudo nano /etc/netplan/01-netcfg.yaml
示例:
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8]
应用:
sudo netplan apply
nmcli connection show
nmcli con mod eth0 ipv4.method manual \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "8.8.8.8"
nmcli con up eth0
sudo nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 1.1.1.1
sudo nano /etc/network/interfaces
dns-nameservers 8.8.8.8
ip a # 查看网卡
ip route # 查看网关
ping 8.8.8.8 # 测试网络
systemctl status networking
请告诉我:
cat /etc/os-release)我可以直接给你对应配置。
如果你能补充:
✅ Debian 版本
✅ 静态 / DHCP
✅ 有线 / 无线
✅ 实体机 / 虚拟机
我可以给你精准配置命令。