bem*_*lit 33 server configuration networking
sudo apt-get update
sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)
ifconfig
sudo nano /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.150
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.1.255
gateway 192.168.2.1
safe
Run Code Online (Sandbox Code Playgroud)sudo nano /etc/resolv.conf
Do not edit this file by hand --your changes will be overwritten
# I add this
nameserver 8.8.8.8
nameserver 8.8.4.4
Run Code Online (Sandbox Code Playgroud)sudo apt-get remove dhcp-client
sudo /etc/init.d/networking restart
*Running /etc/init.d/networking restart is deprecated because it may
not enable again some interfaces
*Reconfiguring network interfaces...
ssh stop/waiting
ssh start/running,process 1438
Run Code Online (Sandbox Code Playgroud)错误在哪里?我不懒。我用谷歌搜索了 3 天,但没有结果。我尝试了一切。
重新启动后,/etc/resolv.conf
文件会闪烁到原始状态。
Jam*_*ess 16
这有两个独立的问题:
resolv.conf
重新启动后条目被重置
/etc/resolv.conf
Ubuntu 12.04 中的工作方式已经改变。这是因为foundations-p-dns-resolving
这里描述
的实现https://blueprints.launchpad.net/ubuntu/+spec/foundations-p-dns-resolving克服了 static 的一些限制resolv.conf
。
在这里您可以获得更多详细信息:http : //www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/
您可以通过删除符号链接/etc/resolv.conf
并创建一个名为/etc/resolv.conf
那里的文件来覆盖新功能。但在这样做之前,请参考我上面给出的链接,看看为什么强烈不鼓励这样做。
IP 地址与网络和网关冲突(设置静态 IP)
此外,正如pgschk 所指出的,您的 IP 地址与网关和网络条目不匹配。但这并不是导致/etc/resolv.conf
进入原始状态,而是我上面提到的原因。
您的网关地址与您的本地 IP 地址位于不同的子网中:
地址 192.168。1 .150 网关 192.168。2 .1
此外,网络地址也在 .2 子网中指定:
网络 192.168。2 .0
您使用 192.168.1/24 还是 192.168.2/24 子网?
编辑: 关于您的 resolv.conf:该文件主要由不同的包更新(取决于您的设置)。尝试在 /etc/network/interfaces 文件中指定名称服务器:
dns-nameservers 8.8.8.8 8.8.4.4