zoukankan      html  css  js  c++  java
  • [Ubuntu] 如何设置静态 IP 和 DNS

    编辑 /etc/network/interfaces 来设置 IP 和 DNS 解析服务器: 

    # interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 192.168.1.6
            gateway 192.168.1.1
            netmask 255.255.255.0
            dns-nameservers 192.168.1.1
            #network 192.168.1.0
            #broadcast 192.168.1.255

    多个 DNS 解析服务器之间使用空格分隔:

    dns-nameservers 192.168.1.1 8.8.8.8

    使修改立即生效:

    sudo ifdown eth0 && sudo ifup eth0

    若未能即时生效,可尝试将 /etc/resolv.conf 设置为 /run/resolvconf/resolv.conf 的软连接:

    ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

    如果只是临时更改 DNS 服务器,编辑 /etc/resolv.conf,添加以下内容:

    nameserver 8.8.8.8 

    resolv.conf 是个动态文件,每次开机会被重新覆盖,因此要添加永久性DNS,采用第一种方式为佳,第一种方式每次开机后会将 dns-nameservers 值写入 resolv.conf 文件中。

  • 相关阅读:
    表单之input的样式修改
    文本省略和文本垂直居中展示
    text-align:justify的使用
    10- 禅道使用
    09- 软件缺陷
    08- 测试用例详解
    07- 场景分析法
    01- Python语言简介
    08. linux下 mv find grep命令
    1.4.19- HTML标签之注释标签
  • 原文地址:https://www.cnblogs.com/ifantastic/p/3422277.html
Copyright © 2011-2022 走看看