2015-06-08 11:26:52
来 源
中存储网
Ubuntu
之前我安装也过Ubuntu server ,因为ubuntu server 没有图形界面,配置静态ip就必须使用vi编辑器来编辑/etc/network/interfaces文件实现,但是就是设置不成功,不知道是什么原因,网上的资料也查询了,都是一个设置方式。 通过不断的实验,终于配置成功,留

之前我安装也过Ubuntu server ,因为ubuntu server 没有图形界面,配置静态ip就必须使用vi编辑器来编辑/etc/network/interfaces文件实现,但是就是设置不成功,不知道是什么原因,网上的资料也查询了,都是一个设置方式。

通过不断的实验,终于配置成功,留下日志备查:

使用vi,输入命令(为了不输入sudo 我直接切换到root账户):

sudo su
vi /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 interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.6
netmask 255.255.255.0
gateway 192.168.0.1

注意对比,配置完成之后,重启网络:

/etc/init.d/networking restart
一旦不是root账户,记得加sudo哦

昨天设置了静态IP,今天再打开电脑的时候却发现服务器不能联网了,奇怪,后来想了想是不是我没有设置DNS的缘故,使用vi编辑器打开/etc/resolv.conf:

vi /etc/resolv.conf
添加DNS:

search mydomain.com
nameserver 61.139.39.73
nameserver 61.139.2.69

配置完成之后,重启网络:

/etc/init.d/networking restart
问题解决!

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。