zoukankan      html  css  js  c++  java
  • Ubuntu16.04配置静态IP地址

    ubuntu如何设置静态IP?

    设置静态IP

    1.编辑/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 eth0#etho为通常的Ubuntu的网关名称,有时也会改变,可通过ifconfig命令查看,有时会出现如ens160,ens33等名称

            iface eth0 inet static#设置IP为静止IP,

            address 192.168.1.103#你想设置的静态IP地址

            netmask 255.255.255.0#子网掩码,通常为255.255.255.0

            #network 192.168.1.0

            broadcast 192.168.1.255 #广播地址,可以通过ifconfig查看现有的。,

            gateway 192.168.1.8#网关, #netstat -r 命令或者   nm-tool   查看现有的

            # dns-* options are implemented by the resolvconf package, if installed

            dns-nameservers 61.139.2.69#国内常见的dns解析,

           #dns-search localhost

            dns-nameservers 8.8.8.8#谷歌dns解析,但是速度较慢

    配置好后就重启网卡:sudo /etc/init.d/networking restart 

    即可查看修改后的系统IP信息。如果无networking文件,则自己创建。

    执行该命令时,可能出现的错误:

    [....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.

    failed!

    后来发现出现这个错误的原因,是因为Ubuntu16.04中的网卡名称不是eth0。

    具体是网卡名称可以通过ifocnfig命令查看,我的机子的网卡名称为enp0s25,有些机子的网卡名称可能是ens33,将eth0改成自己的机子的网卡名称,然后保存推出,重启网络,发现成功了!大功告成。

  • 相关阅读:
    root----TH1
    linux debug
    python基础 文件操作
    linux下挂载硬盘
    安装双系统
    路由器相关
    007-python 获取网卡实时流量(转)
    ssh密钥登录失败(转)
    当while read line 遇到 ssh(转)
    python实用功能之001-邮件发送
  • 原文地址:https://www.cnblogs.com/dengyungao/p/8523348.html
Copyright © 2011-2022 走看看