改为静态 IP?

改为静态 IP?

我正在使用 Ubuntu Server,并尝试将我的连接设置为静态 IP,而不是动态 IP。但是,每当我输入此 /etc/网络/接口

auto wlan0
iface wlan0 inet static
     address 192.168.1.68
     netmask 255.255.255.0
     gateway 192.168.1.64

我的服务器无法连接到互联网。运行类似sudo apt-get 升级,由于我未连接到互联网,因此出现错误。这是什么问题?

答案1

从 12.04LTS 开始,不应使用/etc/resolv.conf。如果网络适配器正在使用 IP 地址,但无法解析域名,请添加

dns-nameservers 1.2.3.4  5.6.7.8

网关条款/etc/network/interface

答案2

您需要指定 DNS 服务器。启用 DHCP 后,您的服务器会自动获取此信息,而静态 IP 则无法实现此功能。

答案3

根据 Ubuntu 服务器指南,您确实需要按如下方式修改 /etc/network/interfaces。

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1
dns-nameservers 8.8.8.8 8.8.8.4
dns-search mydomain.com

然后关机并重启界面:

~$ sudo ifdown eth0 && sudo ifup eth0

https://help.ubuntu.com/14.04/serverguide/network-configuration.html#ip-addressing

相关内容