手机
当前位置:查字典教程网 >操作系统 >Ubuntu/Debian >Ubuntu静态IP Ubuntu上网配置方法
Ubuntu静态IP Ubuntu上网配置方法
摘要:执行命令:vim/etc/network/interfaces编辑内容如下:autoloifaceloinetloopback#网卡eth0...

执行命令:

vim /etc/network/interfaces

编辑内容如下:

auto lo

iface lo inet loopback

#网卡eth0的配置

auto eth0

iface eth0 inet static

address 192.168.1.30 #设置得静态IP

netmask 255.255.255.0

gateway 192.168.1.1

#dns-nameservers 8.8.8.8

#network 192.168.1.0

#broadcast 192.168.1.255

#后面两条是网络号和广播号,这个可以由其它信息计算,因此无需设置

#其中dns-nameservers用于指定dns如果按照下面修改/etc/resolv.conf每次开机都被重置

#可以用去掉#号用这里的dns设置

重启生效

sudo /etc/init.d/networking restart

如果不能上网,也有可能是dns问题

sudo vim /etc/resolv.conf

设置 nameserver 8.8.8.8 即可

如果不是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

问题出现了,重启计算机之后,/etc/resolv.conf中写入的DNS又被清除

解决办法

在/etc/resolvconf/resolv.conf.d/head文件中写入DNS。

vi /etc/resolvconf/resolv.conf.d/head

添加DNS:

search mydomain.com

nameserver 61.139.39.73

nameserver 61.139.2.69

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

/etc/init.d/networking restart

【Ubuntu静态IP Ubuntu上网配置方法】相关文章:

Ubuntu开启.htaccess的支持配置方法分享

Linux/Ubuntu sudo不用输入密码的方法

Ubuntu关闭按钮移到右上角的设置方法

Ubuntu中设置静态IP的方法介绍

Ubuntu 12.04系统配置方法教程(图文)

ubuntu 无线拨号上网方法

在Ubuntu中安装VirtualBox并配置USB设备支持的方法

ubuntu与windows远程连接的方法

ubuntu vsftpd匿名用户上传下载的配置方法

ubuntu 设置IP,设置网关方法分享

精品推荐
分类导航