Ubuntu 14.04静态ip设置

  1. 找到文件interfaces,路径:/etc/network/interfaces
  2. 打开interfaces文件,看到以下内容:

    auto lo
    iface lo inet loopback

    auto dsl-provider
    iface dsl-provider inet ppp
    pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
    provider dsl-provider

    auto eth0
    iface eth0 inet manual

  3. 修改interfaces文件,修改内容如下:

    auto eth0

    #iface eth0 inet manual

    iface eth0 inet static

    address 192.168.1.109

    netmask 255.255.255.0

    gateway 192.168.0.1

    network 192.168.0.0

    broadcast 192.168.0.225

    保存退出。

  4. 修改dns解析

     因为以前会自动分配dns服务器地址,而一旦设置为静态ip后就没有自动获取到的dns服务器了,要自己设置一个

     sudo vim /etc/resolv.conf

     写上一个公网的DNS

     nameserver 202.96.128.86

    (注意:8.8.8.8是谷歌的DNS服务器,但是解析速度慢,还是找到一个国内的dns来用)

     重启后可能出现不能访问外网的情况,这是因为dns又被设置回默认值了

     需要永久修改dns

     sudo vim /etc/resolvconf/resolv.conf.d/base

     重启网卡

     sudo /etc/init.d/networking restart

     如果能上网则说明设置成功且外网能ping通则说明设置成功

posted @ 2015-07-12 11:20  搞不清算法  阅读(2398)  评论(0编辑  收藏  举报