zoukankan      html  css  js  c++  java
  • ubuntu14.04如何设置静态IP的方法

    第一步:

    配置静态IP地址:

    打开/etc/network/interfaces文件,内容为

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet dhcp
    

        

    以上表示默认使用DHCP分配IP,如果想指定静态IP,则需要如下的修改

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static *******定义为静态IP
    
    address 192.168.2.29 *******所要设置的IP地址
    netmask 255.255.255.0 *******子网掩码
    gateway 192.168.2.1 *******网关(路由地址)
    

        

    然后保存此文件

    第二步:

    手动设置DNS服务器

    打开文件/etc/resolv.conf,设置内容如下

    nameserver 192.168.2.1 ******网关(同上)
    

        

    第三步:

    注意:重启Ubuntu后发现不能上网,问题出现在/etc/resolv.conf。重启后,此文件配置的dns又被自动修改为默认值。所以需要永久性修改DNS。方法为

    打开文件/etc/resolvconf/resolv.conf.d/base,写入一下内容:

    nameserver 192.168.2.1
    nameserver 202.106.0.20
    

        

    第四步:

    重启networking服务,使其生效,命令为:

    /etc/init.d/networking restart
    

        

    (亲身经历为:重启此服务无效,还是重启系统给力)

  • 相关阅读:
    pormise的基本用法
    let 与 var 的区别
    字符串
    数组
    Redis 低级数据结构:一、介绍
    Curator使用:(七)分布式Barrier
    Curator使用:(六)分布式计数器
    Curator使用:(五)分布式锁
    Curator使用:(四)Master选举
    Curator使用:(三)事件监听
  • 原文地址:https://www.cnblogs.com/yaohong/p/9483947.html
Copyright © 2011-2022 走看看