美文网首页
Ubuntu16.04下设置静态IP

Ubuntu16.04下设置静态IP

作者: Skye_kh | 来源:发表于2017-05-10 14:21 被阅读185次

    vi /etc/network/interfaces

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto ens160    #设置自动启动ens160接口
    #iface ens160 inet dhcp  
    
    iface ens160 inet static   #配置静态IP
    address 10.1.18.200  #IP地址
    netmask 255.255.255.0  #子网掩码
    gateway 10.1.18.254    #默认网关
    dns-nameserver 210.32.32.10
    

    dns-nameserver 210.32.32.10 这句一定需要有,
    因为以前是DHCP解析,所以会自动分配DNS 服务器地址。
    而一旦设置为静态IP后就没有自动获取到DNS服务器了

    设置完重启电脑

    /etc/resolv.conf 文件中会自动添加

    nameserver 210.32.32.10
    

    (或者nameserver 8.8.8.8)可以根据访问速度,选择合适的公共DNS

    相关文章

      网友评论

          本文标题:Ubuntu16.04下设置静态IP

          本文链接:https://www.haomeiwen.com/subject/aaqgtxtx.html