Debian12设置静态IP
# 备份
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# 注释掉原来的
# allow-hotplug enp3s0
# iface enp3s0 inet dhcp
# 添加
auto enp0s3
iface enp0s3 inet static
address 192.168.18.22
netmask 255.255.255.0
gateway 192.168.18.22
dns-nameservers 8.8.4.4 8.8.8.8
# 重启服务
sudo systemctl restart networking.service
ip addr
修改DNS
nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
sudo systemctl restart networking.service
auto enp0s3
iface enp0s3 inet static
address 192.168.2.3
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 223.5.5.5 119.29.29.29
https://www.publicdns.xyz/
https://www.alidns.com/
https://www.dnspod.cn/products/publicdns
如何在 Debian 12 上分配静态 IP 地址