我(认为)我已经在以下位置配置了一个静态 IP 地址/etc/network/interfaces
:
# The primary network interface
auto eth0
iface eth0 inet static
address 10.1.1.2
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1
Run Code Online (Sandbox Code Playgroud)
我更改文件/etc/resolv.conf
以包含所需的名称服务器。
然后我重新启动网络 sudo /etc/init.d/networking restart
但是几个小时后,resolv.conf 总是恢复到 DHCP 名称服务器。
l0
和eth0
接口的Ubuntu 服务器。