码迷,mamicode.com
首页 > 其他好文 > 详细

Ubuntu静态IP Ubuntu上网配置方法

时间:2014-08-13 21:49:17      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:style   color   使用   文件   ar   art   问题   代码   

1. 执行代码

    vim /etc/network/interfaces

2. 编辑内容

 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设置

3. 重起生效

  ifdown eth0   ,ifup eth0

     (在某些ubuntu中,sudo /etc/init.d/networking restart以及 ifconfig eth0 down/start不生效)

 

4. 如果不能上网,也可能是dns的问题

  执行: sudo vim /etc/resolv.conf   设置 nameserver 8.8.8.8 即可

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

   添加:(你自己的dns)

    search mydomain.com
    nameserver 61.139.39.73
    nameserver 61.139.2.69

     配之后,重启网络:

    ifdown eth0   ,ifup eth0

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

5. 修改 resolvconf服务的配置文件: /etc/resolvconf/resolv.conf.d/head(或者base、tail这三个文件均可)

  添加:    

    search mydomain.com
    nameserver 61.139.39.73
    nameserver 61.139.2.69

6. 执行命令

  $ resolvconf -u  (关于 resolvconf 服务更多信息,可以用man查看:man resolvconf )

  ifdown eth0   ,ifup eth0

Ubuntu静态IP Ubuntu上网配置方法,布布扣,bubuko.com

Ubuntu静态IP Ubuntu上网配置方法

标签:style   color   使用   文件   ar   art   问题   代码   

原文地址:http://www.cnblogs.com/ghli/p/3910837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!