之前我安装也过Ubuntu server ,因为ubuntu server 没有图形界面,配置静态ip就必须使用vi编辑器来编辑/etc/network/interfaces文件实现,但是就是设置不成功,不知道是什么原因,网上的资料也查询了,都是一个设置方式。
通过不断的实验,终于配置成功,留下日志备查:
使用vi,输入命令(为了不输入sudo 我直接切换到root账户):
sudo suvi /etc/network/interfaces配置过后的文件内容为(红色标记为更改添加内容):# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).
# The loopback network interfaceauto loiface lo inet loopback
# The primary network interfaceauto eth0# iface eth0 inet dhcpiface eth0 inet staticaddress 192.168.0.6netmask 255.255.255.0gateway 192.168.0.1
注意对比,配置完成之后,,重启网络:
/etc/init.d/networking restart如果不是root账户,记得加sudo哦
昨天设置了静态IP,今天再打开电脑的时候却发现服务器不能联网了,奇怪,后来想了想是不是我没有设置DNS的缘故,使用vi编辑器打开/etc/resolv.conf:
vi /etc/resolv.conf添加DNS:
search mydomain.comnameserver 61.139.39.73nameserver 61.139.2.69
配置完成之后,重启网络:
/etc/init.d/networking restart问题解决!
更多Ubuntu相关信息见Ubuntu 专题页面 ?tid=2
在时光的激流中,我们总会长大。